How to best disable controls

I have a requirement to build a few windows which have multiple controls on them such as popup menus, text fields etc.

The user wants those fields to be non editable until they manually select an edit mode. My first thought was to set enabled to false for each control until they hit edit, unfortunately and understandably, this causes the controls to be “greyed out” and a bit faint. This will not pass as acceptable.

I’m wondering what others out there have done to get around this issue and whether there are any recommendations?

Upon reflection, the answer is quiet obvious. I’ve subclassed the controls and can check whether the window is in edit mode or not.

For text fields, set readonly=true make them look enabled but the text cannot be modified.

For Popups it’s more complicated. Looking for something similar I ended creating a Dummy Popup Subclass that has his own custom MenuItem property where I really place the required menu options (not on the PopUp object itself). I’ve added too a readonly property to the subclass.

This way you can catch the MouseDown event and when readonly is false, show the MenuItems using PopMenu command in the same coordinates.

1 Like

Thank you Xavier. That is pretty much what I’ve done for the text fields. I’ll try your solution for the popup menus as that was my next challenge.

I use combobox a lot rather than the popup and need to make the combobox readonly.
So what i do is have a new property on my comobox subclass for ReadOnlyYN.
And the keydown_event and mousedown_event, i do the following.
Is there a better way to do this??

if ReadOnlyYN=True THEN
  return True
END IF

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.