【问题标题】:Get value from EditText on enter输入时从 EditText 获取值
【发布时间】: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_functiongotorelativ_up_function

它工作正常,唯一的问题是,用户需要按两次回车来获取编辑文本的当前值。

【问题讨论】:

    标签: matlab user-interface matlab-guide onkeypress


    【解决方案1】:

    我已经解决了。我使用了错误的功能。代码应该在编辑文本的回调函数中使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-15
      • 2020-05-24
      • 2014-07-13
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多