Window key press function and Slider confliction
Mostrar comentarios más antiguos
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 comentarios
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
el 5 de Oct. de 2025
dpb
el 5 de Oct. de 2025
Well that sucks...not much help or even point in that, is there?
Tianlun Yu
el 6 de Oct. de 2025
dpb
el 6 de Oct. de 2025
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Migrate GUIDE Apps en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!