Try to get Content of String of edit-box inside a KeyPressFcn without pressing return
1 回表示 (過去 30 日間)
古いコメントを表示
Christian Schultes
2015 年 10 月 10 日
回答済み: Walter Roberson
2015 年 10 月 10 日
From style edit field make a Callback by KeyPressFcn. I try to read out the content of entire String. But I get an empty string back, until I press "return". Is there a way to get the String back without pressing return?
****
set(hObject, 'KeyPressFcn', {@edit_input_KeyPressFcn(hObject, eventdata, handles});
****
function edit_input_KeyPressFcn(hObject, eventdata, handles)
guidata(hObject, handles);
keyinput = eventdata.Key;
if strcmpi(keyinput, 'comma')
get_txt = get(hObject,'String');
set_txt = strrep(get_txt,',','.');
set(hObject,'String',set_txt);
end
0 件のコメント
採用された回答
Walter Roberson
2015 年 10 月 10 日
No there is not. You will need to keep track of the characters yourself, or you will need to switch to a Java callback. The String property will not be updated until return is entered or another control gains focus.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!