How do I add .editable behavior to .mlapp components?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Cris LaPierre
2023년 3월 30일
편집: Cris LaPierre
2023년 3월 30일
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
Cris LaPierre
2023년 3월 30일
Agreed. Consider submitting a suggestion saying as much here:
(Create Service Reqeust > Technical Support > Product help, bugs, suggestions or documentation errors)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dialog Boxes에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!