Pan mode control via keyboard

2 次查看(过去 30 天)
SSOI SS
SSOI SS 2012-2-28
Hi! I have a problem. If I set command "pan" in the KeypressFcn of a GUI, so that I can use a key to control the pan mode (e.g. "P"). If the pan mode is not on, there is no problem to activate the pan mode. But if I press the key again, then the KeypressFcn will no more be invoked.
If there anyway to let the key alway control Pan on and Pan off?
Thanks

回答(1 个)

Walter Roberson
Walter Roberson 2012-2-28
  2 个评论
SSOI SS
SSOI SS 2012-2-28
Hi Walter, thanks, turning off the WindowListenerHandles is definitive not the solution for me. I attachted an example to show the problem:
function exampleGUI
hF = figure;
set(hF, 'WindowKeyPressFcn', @figKeyPressCallback);
function figKeyPressCallback(fHandle, EventData)
% add some keyshortcuts to SignalViewer
Key = get(fHandle, 'CurrentCharacter');
switch Key
case 'p'
pan;
end
figure(hF);
end
end
There is no way to let the p key always control the pan function ....
Walter Roberson
Walter Roberson 2012-2-28
You turn on pan, you use the Jedi Mind Trick on the listeners, you install a new key press callback. The new key press callback handles everything the regular callback would but also looks for 'p' and if it finds it then then it removes the trick callback and wakes up the listeners and turns pan off.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by