pan cancels WindowKeyPressFcn callback...

Hi,
I noticed that after using the pan function, WindowKeyPressFcn callback doesn't work anymore...
Example:
function someFunction
Fig = figure('WindowKeyPressFcn', @buttonPressed_Callback);
plot(rand(1,10))
pan on
function buttonPressed_Callback(handle, event)
key = event.Key
end
end
How can I reactivate the WindowKeyPressFcn callback after the pan command?
Thanks,
Razvan

 Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Mayo de 2012

0 votos

You are correct, pan does have that effect. Please see http://www.mathworks.com/matlabcentral/answers/30563-pan-mode-control-via-keyboard

3 comentarios

Razvan
Razvan el 10 de Mayo de 2012
Thanks!
Actually I tried the "Jedi Mind Trick" that you suggest in the other thread . My code is now
function someFunction
Fig = figure();
plot(rand(1,10))
addlistener(Fig, 'WindowKeyPress', @keyPress);
pan on
function keyPress(src,evtData)
key = get(src,'CurrentCharacter')
end
end
Now I can capture the key that was pressed, but still the figure disappears after I press a key and I get back to Matlab command window...
Any further suggestions?
Thanks,
Razvan
Walter Roberson
Walter Roberson el 10 de Mayo de 2012
1) *First* turn on pan.
2) Then turn off the listeners as shown at https://groups.google.com/group/comp.soft-sys.matlab/msg/db42cf51392b442a
3) Then set() your desired function as the WindowKeyPress callback.
4) When it is time to turn pan off, reverse the order: set() the WindowKeyPress callback to what it would normally be, then re-enable the listeners, then turn pan off.
addlistener() is not involved in this process: you need to disable the listeners instead as the listeners are blocking you from adding your own WindowKeyPress callback.
Chella
Chella el 23 de Jul. de 2014
Editada: Chella el 24 de Jul. de 2014
I know this is an old thread but it helped me out. In addition to step 3) I also have to set KeyPressFcn = [] to avoid keystrokes getting back to Matlab command window.
Thanks

Iniciar sesión para comentar.

Más respuestas (1)

Sean de Wolski
Sean de Wolski el 10 de Mayo de 2012

0 votos

Hi Razvan,
I think this thread might interest you:

1 comentario

Razvan
Razvan el 10 de Mayo de 2012
Thanks, but I couldn't solve this problem yet.
Razvan

Iniciar sesión para comentar.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Preguntada:

el 10 de Mayo de 2012

Editada:

el 24 de Jul. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by