Window key press function and Slider confliction
古いコメントを表示
Hello, I need to use arrow key to move the crosshair in the figure. This function (crosshair moving) works well in GUIDE and app designer. However, the window key press function behaves differently between app designer and GUIDE.
Let's say I have some buttons, a slider, and an axes/uiaxes in the window. The slider is used to control the gamma of the image.
In GUIDE, when the slider is focused and pressing arrow key, it won't trigger the WindowKeyPressFcn, which means the slider moves (so the gamma changes), but the crosshair in the figure (axes1) doesn't move.
However, in app designer, when the slider is focused, pressing arrow key will trigger both the slider and Window key press function. This results in both gamma changing and crosshair moveing. I don't want such behavior.
Is there a way to make this function behave the same as in the GUIDE?
5 件のコメント
The WindowKeyPressFcn callback receives a KeyData object as the second argument. event.Source is the handle of the object that had focus when the key was pressed so you can identify when it is the slider is in focus and prevent the crosshair from moving when the left/right arrow keys are pressed.
You might also submit this to Mathworks as an official support request about alternate behavior at <Product Support Page> and see if there might be more sophisticated technique or if Mathworks would consider an enhancement to be able to control the WindowKeyPress callback with more granularity. Indeed, it seems like perfectly reasonable behavior desired..
Tianlun Yu
2025 年 10 月 5 日
dpb
2025 年 10 月 5 日
Well that sucks...not much help or even point in that, is there?
Tianlun Yu
2025 年 10 月 6 日
dpb
2025 年 10 月 6 日
OK, thanks. I didn't see any reference in the documentation that there were additional fields; think that would be worth submitting as documentation enhancement. Of course if one is in the debugger one can go poking and would be able to see it, but would have to think of that being what had been done with no prior hints.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!