【matlab】GUI CreateFcn+Callback+keypressfcn用法

CreateFcn+Callback+KeyPressFcn



  • % --- Executes during object creation, after setting all properties.
  • CreateFcn是在设定所有属性之后,建立这个对象控件时就触发

  • % --- Executes on button press in XXX.
  • XXX_Callback是在点击或者按下或者选中时才触发的回调函数。

  • % --- Executes on key press with focus on password and none of its controls.
  • KeyPressFcn是在     触发

    keypressfcn

    大部分的控件都有keypressfcn這個callback,但是當GUI在執行中,使用者按下了鍵盤,你的GUI程式怎知道要執行那個元件的keypressfcn?
    GUI執行keypressfcn的邏輯是:只有取的「焦點」(focus)的那個元件的keypressfcn會回應按鍵動作。
    所以執行GUI時,您得決定讓那個元件取得focus,這樣,那個控件的keypressfcn才能在鍵盤被按下時被執行。
    控件取得focus的方式為:
    uicontrol(handles.Tag_Name)
    其中Tag_Name為該控件的Tag



% --- Executes on key press with focus on password and none of its controls.
function password_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to password (see GCBO)
% eventdata  structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)

% - - - - - -执行与关注密码按键,没有它的控制。

函数password_KeyPressFcn(hObject eventdata,处理)

% hObject处理密码(见GCBO)

% eventdata结构以下字段(参见UICONTROL)

%的关键:名称键被按下,在较低的情况下

%字符:字符解释的关键(s)

%修饰符:名称(s)(s)(即修饰符的关键。、控制、转移)

%处理结构处理和用户数据(见GUIDATA)


  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值