How do I add .editable behavior to .mlapp components?
3 views (last 30 days)
Show older comments
Some mlapp components have a .editable property that allows or disallows editing of the value. An example is the numeric edit field, where you can allow or disallow editing the value displayed by setting the .editable property for the component. However, not all components that hold a value have a .editable property. An example of this is the check box. The check box has a value (app.checkbox.Value) that can be changed by clicking the check box, but there is no .editable property that I can set to allow or disallow this editing.
Is there a way to add this .editable property and behavior to mlapp components that lack it? examples of components that lack the behavior include the check box, switch, dropdown menu.
For context: I'm building a gui in the matlab app designer that will control an expensive piece of equipment. The equipment has many settings that the user may adjust via the gui. I have a switch on the gui called "enable editing" that sets the .editable status of all edit fields to off unless the switch is flipped to the on state. This acts as a safety to prevent unintended and potentially damaging changes to the configuraion. This setup works perfectly for all of the numeric edit fields but I can't figure out how to add this safety feature to check boxes, switches, and dropdowns.
It is possible to set the .enable property on these components to off, but that has unintended consequences from a user interface perspective. Components are greyed out and very hard to see while disabled, which communicates to the user that the setting is not relevant, isn't used, or something along those lines. That's not at all what I want. The current state of the check box is extremely important and should remain perfectly visible - I just don't want a misclick to change its status. I've made a quick dummy app showing the difference using a check box. A screenshot is shown below.
0 Comments
Accepted Answer
Cris LaPierre
on 30 Mar 2023
Edited: Cris LaPierre
on 30 Mar 2023
You can see all the checkbox properties here: https://www.mathworks.com/help/matlab/ref/matlab.ui.control.checkbox-properties.html
There is not an 'Editable' property for checkboxes. Since it appears you want the checkbox to be view only, which means its value is getting set programmatically elsewhere in your app, you could make the checkbox callback just be a function that returns the checkbox back to whatever value it had before.
% Value changed function: CheckBox
function CheckBoxValueChanged(app, event)
value = app.CheckBox.Value;
if value==1
app.CheckBox.Value = 0;
else
app.CheckBox.Value = 1;
end
end
4 Comments
Cris LaPierre
on 30 Mar 2023
Agreed. Consider submitting a suggestion saying as much here:
(Create Service Reqeust > Technical Support > Product help, bugs, suggestions or documentation errors)
More Answers (0)
See Also
Categories
Find more on Dialog Boxes 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!