GUIDE: call an element from the Property Inspector.
5 views (last 30 days)
Show older comments
Hi everyone, I'm using GUIDE to generate just .fig files. I want to recall an element in my GUI [like set(TagElement,'Enable','off')] when something happens in another element. e.g. I want to deactivate an edit text if the user selects one CheckBox. should I write the command set in the callback space of the checkbox, in Property inspector? I'm just generating .fig so I cannot write it in any .m file. How can I identify the edit text element?
3 Comments
Adam
on 9 Nov 2015
If you want there to be any logic under your UI you will have to have a .m file of some sort associated with it, whether that is the auto-generated one or .m files you write yourself. Otherwise you are simply defining the look of the GUI and cannot impose any functionality on it.
Answers (1)
Image Analyst
on 9 Nov 2015
You WILL have an m-file associated with it - it's not just a fig file all by itself. So in the callback function for the checkbox, say
checkBoxStatus = get(handles.checkbox1, 'Value');
if checkBoxStatus
% Checkbox is checked so disable the edit field.
set(handles.edit1, 'Enable', 'off');
else
% Checkbox is not checked so enable the edit field.
set(handles.edit1, 'Enable', 'on');
end
2 Comments
Image Analyst
on 9 Nov 2015
Not that I'm aware of. The callback function as defined in the property inspector just gives the name of a callback function. I don't know if you can put actual code into that property instead of just the name of a callback function. I would doubt it but you'd have to call the Mathworks to make sure.
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!