TA的每日心情 | 衰 2019-11-19 15:29 |
|---|
签到天数: 1 天 [LV.1]初来乍到
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
6 m$ B( l1 ~' U, g, M做了个查询工具,通过调用pushbutton的回调函数,查询Edit Text中输入的文件是否存在,如果文件名还没有输入,则报错。2 {! ~1 S H6 }( r; p
下述程序中edit1的初始string为'Please input the function you need help!'
; w4 g# l# q5 @& m! i8 E, e2 S/ n6 Q
0 x, G; | z( Y0 [! S8 f3 Y问题是,当在edit1中更新输入后,点击pushbutton1, 没有问题;: o/ S, Y( c6 P
但更新输入后,如果按"Enter"键,则会跳出errordlg,点击确认后,再按"Enter"键,则没有问题。问题原因应该是:更新输入后,直接按回车键,
. r9 |* r, p0 s H# a3 E& m% v5 Y) ?8 t获得的edit1的string内容,仍然是更新前的。
- S4 z$ d3 S0 J! d) q) h, d* T4 w请帮助解惑,谢谢!1 p9 z1 ]/ }% E5 U* R) h1 y6 D
* C% P% d9 l; H$ i3 K0 g$ q! F
- function pushbutton1_Callback(hObject, eventdata, handles)
- str = get(handles.edit1,'string'); %获取可编辑文本框中字符串数据;
- if isequal(str,'Please input the function you need help!')
- errordlg('输入数据错误','warn'); %跳出错误对话框,msgbox、questdlg
- return
- end
- function figure1_WindowKeyPressFcn(hObject, eventdata, handles)
- str = eventdata.Key;
- if strcmp(str, 'return')
- pushbutton1_Callback(handles.pushbutton1, eventdata, handles);
- end
3 r; v: N# M4 T% m& c' B
|
|