Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Hide and disable uicontrols in groups

Subject: Hide and disable uicontrols in groups

From: Matt J

Date: 18 Apr, 2013 21:45:10

Message: 1 of 4


I'm designing GUIs where, sometimes, I want whole groups of uicontrols to be hidden from and inaccessible to the user. The tedious way to do this would be to set the Enable and Visibility properties to 'off' for each button individually. However, I was hoping for some way to designate them as a group and hide them using a single property set.

My first thought was to put them all on a uipanel and control them all through that. This works fine for controlling Visibility. Setting the panel's visibility property off hides everything. However, there doesn't seem to be a corresponding Enable property in a uipanel that can be used to deactivate all the uicontrols residing within it. I tried the HitTest property. That didn't work.

Any recommendations for how best to do this?

Subject: Hide and disable uicontrols in groups

From: Bruno Luong

Date: 18 Apr, 2013 22:18:09

Message: 2 of 4

What about using findobj in the panel to find all the objects to be enabled or disabled?

Bruno

Subject: Hide and disable uicontrols in groups

From: Yair Altman

Date: 18 Apr, 2013 22:20:16

Message: 3 of 4

"Matt J" wrote in message <kkpph6$riu$1@newscl01ah.mathworks.com>...
>
> I'm designing GUIs where, sometimes, I want whole groups of uicontrols to be hidden from and inaccessible to the user. The tedious way to do this would be to set the Enable and Visibility properties to 'off' for each button individually. However, I was hoping for some way to designate them as a group and hide them using a single property set.
>
> My first thought was to put them all on a uipanel and control them all through that. This works fine for controlling Visibility. Setting the panel's visibility property off hides everything. However, there doesn't seem to be a corresponding Enable property in a uipanel that can be used to deactivate all the uicontrols residing within it. I tried the HitTest property. That didn't work.
>
> Any recommendations for how best to do this?


Create a variable that holds an array of the relevant handles, and then enable/disable/hide/display them all at once:

hButtons = [hButton1, hButton2, hButton3];
set(hButtons, 'Enable','off');

Yair Altman
http://UndocumentedMatlab.com
 

Subject: Hide and disable uicontrols in groups

From: Matt J

Date: 18 Apr, 2013 22:57:17

Message: 4 of 4

"Yair Altman" wrote in message <kkprj0$3sd$1@newscl01ah.mathworks.com>...
>
> Create a variable that holds an array of the relevant handles, and then enable/disable/hide/display them all at once:
>
> hButtons = [hButton1, hButton2, hButton3];
> set(hButtons, 'Enable','off');
>
==============

Together with Bruno's suggestion to use findobj to construct hButtons, that isn't too bad. I still kind of wonder why uipanels don't have an Enable property...

 

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us