【发布时间】:2014-08-05 07:29:17
【问题描述】:
我的keypressfcn 有点问题。如果用户在edittextbox中输入一些东西,如果他们按下回车,我想从另一个m文件启动一个函数。
其实是这样的:
% --- Executes on key press with focus on ET_variabelpos_9 and none of its controls.
function ET_variabelpos_9_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to ET_variabelpos_9 (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)
%Modifier um zu überprüfen, ob die Pfeiltastengedrückt wurden
val=double(get(gcf,'CurrentCharacter'))
%28 => leftArrow
%29 => rightArrow
%30 => upArrow
%31 => downArrow
if val == 30
sw1 = get(handles.ET_variabelpos_9,'String')
%Relative Position anfahren (Hoch)
gotorelativ_up_function(sw1,0,8);
elseif val == 31
sw1 = get(handles.ET_variabelpos_9,'String')
%Relative Position anfahren (Hoch)
gotorelativ_down_function(sw1,0,8);
end
我从 EditText 读取值并将其传输到函数 gotorelativ_down_function 或 gotorelativ_up_function。
它工作正常,唯一的问题是,用户需要按两次回车来获取编辑文本的当前值。
【问题讨论】:
标签: matlab user-interface matlab-guide onkeypress