MATLAB Answers


How to add a keyboard shortcut to a menu?

Meshooo 님이 질문을 제출함. 10 Nov 2016
최근 활동 Meshooo 님이 댓글을 추가함. 11 Nov 2016
Dear all,
I want to add a keyboard short cut to a menu. Is that possible?
My sample code as follows:
again = true;
CellCount = 0;
while again && CellCount < 500
choice = menu('Select the Image You Want.', ...
if choice ==1;
figure, imshow('cameraman.tif');
% or press a in the keyboard
if choice ==2;
figure, imshow('circles.png');
% or press b in the keyboard
if choice ==3;
figure, imshow('coins.png');
% or press c in the keyboard
Is there a way to make such a keyboard shortcut?
Any help will be appreciated.

  댓글 수: 0

로그인 to comment.

답변 수: 1

Adam 님의 답변 10 Nov 2016
 채택된 답변

If you are using a uimenu you can, but 'menu' that you are using is basically a dialog box and it is not recommended to use (in R2016b at least) with 'dialog' recommended instead.
If you write your own menu in GUIDE or programmatically then you can support any keyboard shortcuts you want, but the built in dialog or menu are very simplistic so don't support this option.

  댓글 수: 1

OK, thank you very much Adam.

로그인 to comment.

Translated by