How to add a keyboard shortcut to a menu?

1 回表示 (過去 30 日間)
Meshooo
Meshooo 2016 年 11 月 10 日
コメント済み: Meshooo 2016 年 11 月 11 日
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.', ...
'A','B','C');
if choice ==1;
figure, imshow('cameraman.tif');
% or press a in the keyboard
end
if choice ==2;
figure, imshow('circles.png');
% or press b in the keyboard
end
if choice ==3;
figure, imshow('coins.png');
% or press c in the keyboard
end
end
Is there a way to make such a keyboard shortcut?
Any help will be appreciated.
Meshoo

採用された回答

Adam
Adam 2016 年 11 月 10 日
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 件のコメント
Meshooo
Meshooo 2016 年 11 月 11 日
OK, thank you very much Adam.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by