How to keep the zoom active as long as a key is pressed?

조회 수: 1 (최근 30일)
Vlad Atanasiu
Vlad Atanasiu 2015년 5월 30일
댓글: Walter Roberson 2016년 6월 5일
I want the zoom to be activated by pressing a key and stay active as long as the key is pressed. With the following code, unfortunately, the zoom is activated at key press, then focus is transferred from the figure to the command window, and the pressed key is output at the command line as long as hold down. Any suggestion for a solution?
The utility of keeping the zoom active by key press is to have a faster entry/exit in zoom mode than clicking on the two toolbar icons.
function zoomOnKeyPress()
figure(...
'KeyPressFcn', @KeyPressFcn, ...
'KeyReleaseFcn', @KeyReleaseFcn);
function KeyPressFcn(h,e)
zoom on
hf = gcf;
hf.Color = 'red'; % show that we are here
function KeyReleaseFcn(h,e)
zoom off
hf = gcf;
hf.Color = 'green'; % show that we are here

답변 (1개)

Walter Roberson
Walter Roberson 2015년 5월 31일
  댓글 수: 4
Igor
Igor 2016년 6월 4일
편집: Igor 2016년 6월 4일
If anyone is still looking for an answer - the difference between R2014b and older versions is not very large - the fix is described here. For a more complete example, take a look at this submission.
Walter Roberson
Walter Roberson 2016년 6월 5일
Thanks, Igor.

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by