Are there hot keys (shortcuts) that enable interactive mouse controlled pan and zoom for a figure?

조회 수: 34 (최근 30일)
I have MANY global satellite data swaths that are displayed with geoshow() output. We need to zoom into specific regions quickly and pan around in those areas with mouse (not keyboard) input. The behavior of the "zoom-in" magnifying glass and "pan" hand that are enabled from the Tools pull down menu of the default File toolbar for figures is perfect. What i'm looking for is a way to enable those controls (and switch between them) quickly with hotkeys instead of having to access that Tools pull down for every mode change.
Docs describe keyboard controls for zoom in and pan. Neither work in my figure output and we want the mouse (vs. keyboard) control anyway.
Thanks!
  댓글 수: 1
Mike Wilson
Mike Wilson 2015년 3월 2일
Thanks Sean. The techniques in your Zoom Key script are useful, but not exactly what I am looking for. What I need is a way to switch between pan and zoom with a hotkey. Right now I do it with a UI button that triggers either pan on; or zoom on; but that means users have to move the cursor to those buttons in order to trigger the interaction mode change. What I'm looking for is a way to do that with just a key press vs. a mouse click. I want to eliminate the cursor travel.

댓글을 달려면 로그인하십시오.

채택된 답변

Sean de Wolski
Sean de Wolski 2015년 3월 4일
Here's a way that works by using the uimenu's accelerator option. There will be a menu you could use or ctrl + letter to activate:
function HotKeyAcc
% A figure
fig = figure('menubar','none');
% Add menus with Accelerators
mymenu = uimenu('Parent',fig,'Label','Hot Keys');
uimenu('Parent',mymenu,'Label','Zoom','Accelerator','z','Callback',@(src,evt)zoom(fig,'on'));
uimenu('Parent',mymenu,'Label','Rotate','Accelerator','r','Callback',@(src,evt)rotate3d(fig,'on'));
uimenu('Parent',mymenu,'Label','Pan','Accelerator','p','Callback',@(src,evt)pan(fig,'on'));
% Some plot
plot(rand(1,50))
end
  댓글 수: 2
Mike Wilson
Mike Wilson 2015년 3월 4일
Awesome! Thanks very much Sean!
I did have to swap out the letter p for Pan. Pressing Ctrl + P brings up the Print dialog. No worries with that. I would have swapped out the p anyway as I want this mode switch to be accessible with one hand.
A question - you mention that there will be a menu I can use. I assume that would be if I did NOT want to use the ctrl + letter to activate. How would I access that menu and make changes?
Thanks again!
Sean de Wolski
Sean de Wolski 2015년 3월 5일
To make changes to the menu, you'd have to do it programmatically. To make a selection change, just select:

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2015년 2월 24일
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2015년 3월 2일
I don't know if that's possible or not. Attached I have what looks like it should work and it does for turning them on. However, the zoom/pan operation changes the 'KeyReleaseFcn' so it looks like you still have to disable it manually without a Hot Key.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by