waitforbuttonpressf​h

バージョン 1.0.0 (1.43 KB) 作成者: Andrew Diamond
like waitforbuttonpress but for specified figure handle including uifigure.
ダウンロード: 21
更新 2020/5/29

ライセンスの表示

based off of contribution "getkey", like waitforbuttonpress, this causes a uiwait to occur until a key is pressed but with respect to the given figure. As a bonus, the key is returned. (Note the keypressfcn returns multichar strings for non-ascii characters, e.g. 'return' for Enter)

It is useful in the context of App Designer uiFigure which, at least in 2019b, had its HandleVisibility property hard coded to 'off' and was unsettable which meant it would never be gcf and so never be able to be used by waitforbuttonpress. In my particular use, since imrect doesn't work with uifigure (not sure about 2020a), I used drawrectangle but that's asynchronous and I needed it to wait (like imrect).

R=drawrectangle(app.axBF);
ch = waitforbuttonpressfh(app.UIFigure)

Note, though by spec getkey itself would seem to be sufficient for this purpose, it could fail with drawrectangle, after adjusting it, causing the terminating/resuming key press to be ignored. (I believe that's due to its use of strings in its keypress callback which uses gcbf which perhaps changes due to drawrectangle and then gets evaluated in its environment? Just a guess. I used a callback w/o strings).

This also works in compiled apps.

I haven't tested this with other versions but I would think this should work with any any version that had a 'keypressfcn' callback/property for its figure/uifigure.

引用

Andrew Diamond (2024). waitforbuttonpressfh (https://www.mathworks.com/matlabcentral/fileexchange/76363-waitforbuttonpressfh), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2019b
R2019b 以降のリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
タグ タグを追加
謝辞

ヒントを得たファイル: getkey

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0