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

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.

 採用された回答

Doug Hull
Doug Hull 2011 年 1 月 13 日
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');

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAnimation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by