Why does the BackgroundColor of an editable textbox remain white when it has been set to another color in MATLAB 7.7 (R2008b)?

10 views (last 30 days)
I created an editable text box with a BackgroundColor of [0 0.7 0.7]. If I assign a value to the 'String' property while the 'Enable' setting is 'off', the resulting text box will be white isntead of the assigned BackgroundColor. This is contingent upon both setting the String value and the Enable off
%%works
fh=figure
t=uicontrol(fh,'Style','edit','BackgroundColor',[0 .7 .7],'Enable','off')
set(t,'Enable','on')
%%works
fh2=figure
t2=uicontrol(fh2,'Style','edit','BackgroundColor',[0 .7 .7])
set(t2,'String','Hello World')
set(t2,'Enable','on')
%%breaks
fh3=figure
t3=uicontrol(fh3,'Style','edit','BackgroundColor',[0 .7 .7],'Enable','off')
set(t3,'String','Hello World')
set(t3,'Enable','on')
GUIs created in GUIDE are also affected.

Accepted Answer

Doug Hull
Doug Hull on 13 Jan 2011
This is a expected behavior in the way that MATLAB displays the BackgroundColor for editable text objects. To change this, set the 'Enable' property to 'on' before setting STRING’ property as shown below:
fh=figure
t=uicontrol(fh,'Style','edit','BackgroundColor',[0 .7 .7],'Enable','off')
set(t,'Enable','on');
set(t,'String','Hello World');

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!