我的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
。
它工作正常,唯一的问题是,用户需要按两次输入才能获得edittext的当前值。
答案 0 :(得分:0)