Is there a way to do this?
Does being not-enabled specifically prevent this? Are you asking for an automatic method, like whenever you set something's enable to "off" it automatically recolors it too? And are you sure you dont just want to set "enable" to "disabled" (I've never found a good use for enable=off)
f=findobj(gcf,'type','uicontrol','enable','off')
set(f,'color',[1 0 0])
Does it? I did not know that. Is there a workaround?
I'm not sure exactly what you mean by 'automatic'. I don't want to change any Matlab defaults. I just would like to know if there is a way to change the color of the text when the 'Enable' property is set to 'off'. A simple line of code.
I'm also not sure what you mean by 'disabled'? Doesn't setting 'Enable' to 'off' disable the uicontrol?
Currently I am using Java to get around this problem.
Thanks for the help. If you have any suggestions, let me know.
"Nate Jensen" <nateje...@gmail.com> wrote in message
news:j6vavp$674$1...@newscl01ah.mathworks.com...
> "matt dash" wrote in message <j6v8km$r3q$1...@newscl01ah.mathworks.com>...
>> Does being not-enabled specifically prevent this? Are you asking for an
>> automatic method, like whenever you set something's enable to "off" it
>> automatically recolors it too? And are you sure you dont just want to set
>> "enable" to "disabled" (I've never found a good use for enable=off)
>>
>> f=findobj(gcf,'type','uicontrol','enable','off')
>> set(f,'color',[1 0 0])
>
> Does it? I did not know that. Is there a workaround?
>
> I'm not sure exactly what you mean by 'automatic'. I don't want to change
> any Matlab defaults. I just would like to know if there is a way to
> change the color of the text when the 'Enable' property is set to 'off'.
> A simple line of code.
>
> I'm also not sure what you mean by 'disabled'? Doesn't setting 'Enable'
> to 'off' disable the uicontrol?
Write a two-line function to do this.
function disableUicontrolAndChangeColor(uicontrolHandle, desiredColor)
set(uicontrolHandle, 'Enable', 'off', 'Color', desiredColor);
Call this function in your code whenever you need to disable a uicontrol and
change its color. You can write a similar two-line
enableUicontrolAndChangeColor function to reverse the process. You can, of
course, make this more elaborate: some things you might want it to do
include having disableUicontrolAndChangeColor return the color prior to
disabling the uicontrol, or return an onCleanup object that restores the
previous color when deleted, or ...
--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
Thanks, but there is no property 'Color' for uicontrols. Also, setting 'ForegroundColor' does not work. I am using R2011b. Maybe changes there were changes made to the properties of uicontrols?
h = uicontrol('Style','text','String','a');
set(h,'Enable','off','ForegroundColor','k')
Running the above code does not change the font color.
Thanks for the help though.