Setting KeyPressFcn on current figure

3 次查看(过去 30 天)
Jaap
Jaap 2012-2-10
Hi all,
I have defined a KeyPressFcn (or WindowKeyPressFcn) for a figure. Now I want to keep that callback active while another figure has focus. Is this possible? Figure callbacks seem not to work on current figures but on focused figures. Can I change that, or is there some other solution?
Thanks!
Jaap

回答(2 个)

Sean de Wolski
Sean de Wolski 2012-2-10
No, the figure with the callback has to have focus. You could have a new figure take over with the keypressfcn while it's active perhaps. We'd need more detail to help you with a solution.

Jaap
Jaap 2012-2-13
Thank you. This spares me from continuing that search.
My main window is a scatterplot. The user can select a point, and create a plot showing characteristics of that point. On the main window, arrow keys can move a selected point. I want that behaviour being reflected in both (figure) windows.
Could you reflect a bit on "having a new figure take over with the keypressfcn while it's active"?
  1 个评论
Sean de Wolski
Sean de Wolski 2012-2-13
So the callback (keypressfcn) on the scatterplot that opens the new figure should pass it information with the handle to that point, the figure/axes handles and any other information it might need. Then it sets the keypressfcn of the new figure to do what you want (I would keep this callback in a standalone *.m file). The behavior that you want is completely feasible.
I hope this helps. Post more information if you want more detail.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by