Hi,
I have edit text in guide. When I write anything to edit, then I want enable pushbutton. So, how can I do this?
. . . set(handles.pushbutton, 'enable','on');

 採用された回答

Sean de Wolski
Sean de Wolski 2012 年 2 月 22 日

1 投票

function exampleEditEnable
%Build stuff
hFig = figure;
hBut = uicontrol('style','push','units','norm','position',[0 0 0.3 0.1],'enable','off','string','can''t touch this'); %a button
hEdit = uicontrol('style','edit','units','norm','position',[0.5 0.5 0.3 0.1],'string','edit me, I dare you!','callback',@enableButton); %an edit box
function enableButton(varargin)
set(hBut,'enable','on');
set(hBut,'string','can touch this');
end
end
To translate this into GUIDE just use handles.edit and handles.pushbutton etc.

7 件のコメント

john
john 2012 年 2 月 22 日
can you help me?...maybe my code is wrong, cause it doesn't work
function edit5_Callback(hObject, eventdata, handles)
h=findobj(0,'Type','figure','Tag','figure1');
set(handles.edit5,'callback',@enableButton);
function enableButton(varargin)
set(handles.pushbutton4,'enable','on');
end
set(h,'UserData',UserData);
guidata(hObject, handles);
Sean de Wolski
Sean de Wolski 2012 年 2 月 22 日
way too much effort, if edit5 is the ditbox and pushbutton4 is the pushbutton, all you need is:
function edit5_Callback(hObject,eventdata,handles)
set(handles.pushbutton4,'enable','on');
Tada!
john
john 2012 年 2 月 22 日
thank you man,,,,,,so easy :-)
john
john 2012 年 3 月 1 日
So but I have to press ENTER to make pushbutton4 to enable on. So, how can I enable on, when I insert mouse cursor into edit5?
Sean de Wolski
Sean de Wolski 2012 年 3 月 1 日
Add a 'preset' listener to the 'selected' property of the edit box.
doc addlistener
john
john 2012 年 3 月 1 日
I doesn't have 'selected' in property inspector ....
Sean de Wolski
Sean de Wolski 2012 年 3 月 1 日
web([docroot '/techdoc/ref/uicontrol_props.html'])

サインインしてコメントする。

その他の回答 (1 件)

Kevin Holst
Kevin Holst 2012 年 2 月 22 日

0 投票

you would put that code that you wrote in the edittext callback function.

カテゴリ

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

タグ

質問済み:

2012 年 2 月 22 日

編集済み:

2013 年 10 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by