MATLAB: Static Text Handle Creation

handlessetstatic textvisible

Hello All,
I have a hopefully quick and easy question for you guys that I need help answering. I have looked around for quite a while and it is my understanding that handles are not automatically created for static text boxes, at least those that are made in GUIDE, which mine is. I have created the callback function and in it there is a comment that says:
"handles empty – handles not created until after all CreateFcns called"
What I am trying to do is have an error come up if the user inputs an incorrect number in an editable text box. This will be done by first setting the Static Text visibility to off. I can already achieve this by writing "set(hObject, 'visible', 'off'); " in the callback function for the text box. However, using hObject is only possible within the callback for that function so I am trying to use the handle like from a normal push button: "set(handles.ErrorText, 'visible', 'on'); " to be created after a push button is pressed and it does not work.
If it is because of the fact that no handle has been created for it, could you help me learn how to make one because I can't figure it out.
Any help will be much appreciated. Thanks

Best Answer

there should be a tag associated with the static text. default is "handles.text1", it doesn't create functions like the other uicontrols since it is usually just used as static text. so i am not sure what you're accomplishing with the set(hObject....) within the text box as that would turn the text box visibility off.
i created a simple GUIDE gui with a button and a static text field (set property value to be visible off). Then i put
set(handles.text1,'visible','on')
under the button callback.
Running this simple gui, i can turn the static text field to be visible when i push the button.
example of my test gui containing just a static text with tag text1 and a pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
status = get(handles.text1,'visible');
switch status
case 'on'
set(handles.text1,'visible','off');
case 'off'
set(handles.text1,'visible','on');
end