MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

tonybabel
0

How use keyboard arrow keys to control the slider GUI in App Designer?

tonybabel
さんによって質問されました 2019 年 2 月 14 日
最新アクティビティ Rik
さんによって コメントされました 2019 年 2 月 18 日
GUIslider.png
Hi,
I have trouble using keyboard input (like arrow keys) to control a slider GUI in App Designer. For example, when pressing the left arrow key, the slider cursor move to left and pressing the right arrow the slider cursor move to right. I'm trying to use switch/case but totally have no idea what need to be written under each 'case'. Please help! Thank you so much!
Below is the codes I grabbed from "code view" window in App Designer.
% Value changing function: Slider
function SliderValueChanging(app, event)
changingValue = event.Value;
set_param('Output','Value',num2str(changingValue));
end
% Key press function: UIFigure
function UIFigureKeyPress(app, event)
switch event.Key
case 'left arrow key'
??????
case 'right arrow key'
??????
end

  0 件のコメント

サインイン to comment.

1 件の回答

回答者: Rik
2019 年 2 月 14 日

You can use this tester GUI to determine what you should put for the special keys. Don't forget the otherwise option to exit the function if you don't want to respond to other keys.
figure(1),clf(1)
set(gcf,'KeyPressFcn',@keycall)
function keycall(h,e)
disp(e.Key)
end
%rightarrow and leftarrow are the left and right arrow key names

  1 件のコメント

Rik
2019 年 2 月 18 日
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.

サインイン to comment.



Translated by