<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Enabling user callbacks during zoom/pan	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=enabling-user-callbacks-during-zoom-pan</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Mon, 17 Jan 2022 02:41:14 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Tommy		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-513148</link>

		<dc:creator><![CDATA[Tommy]]></dc:creator>
		<pubDate>Mon, 17 Jan 2022 02:41:14 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-513148</guid>

					<description><![CDATA[Just adding my implementation inspired by Sebastian and i3v. 

It handles the state reset that occurs when uimode changes. Also, has options to ignore/append for specific modes.
&lt;a href=&quot;https://github.com/tommyhosman/UseMyKeypress&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;https://github.com/tommyhosman/UseMyKeypress&lt;/a&gt;

Only tested with 2019b and uses &lt;code&gt;event.proplistener()&lt;/code&gt;
]]></description>
			<content:encoded><![CDATA[<p>Just adding my implementation inspired by Sebastian and i3v. </p>
<p>It handles the state reset that occurs when uimode changes. Also, has options to ignore/append for specific modes.<br />
<a href="https://github.com/tommyhosman/UseMyKeypress" target="_blank" rel="nofollow">https://github.com/tommyhosman/UseMyKeypress</a></p>
<p>Only tested with 2019b and uses <code>event.proplistener()</code></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sebastian Hölz		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-510105</link>

		<dc:creator><![CDATA[Sebastian Hölz]]></dc:creator>
		<pubDate>Thu, 04 Mar 2021 23:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-510105</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-508323&quot;&gt;Donato&lt;/a&gt;.

OK, Been working on this again and found a solution which works in 2020a and 2020b. Below a working example which resets the KeyPressFcn for all ui-modes after activating them. It seems it is necessary to reset the 3rd KeyPressFcn, don&#039;t ask me what the others are for ...

&lt;pre lang=&quot;Matlab&quot;&gt;
HV = &#039;off&#039;;
fig = figure(&#039;HandleVisibility&#039;,HV);
ax  = axes(&#039;Parent&#039;,fig, &#039;HandleVisibility&#039;,HV);
plot(rand(1,12),&#039;k.-&#039;, &#039;Parent&#039;,ax)
    
hManager = uigetmodemanager(fig);
addlistener(hManager,&#039;CurrentMode&#039;,&#039;PostSet&#039;,@MonitorModeChange);
    
function MonitorModeChange(varargin)
%hManager = uigetmodemanager(fig);
    if ~isempty(hManager.CurrentMode)
        switch hManager.CurrentMode.Name
            case &#039;Exploration.Brushing&#039;
                disp(&#039;Brushing on&#039;)
                [hManager.WindowListenerHandles.Enabled] = deal(false);
                fig.KeyPressFcn{3} = @(h,e)disp(&#039;Brush KeyPressFcn replacement&#039;);
            case &#039;Exploration.Pan&#039;
                disp(&#039;Pan on&#039;)
                [hManager.WindowListenerHandles.Enabled] = deal(false);
                fig.KeyPressFcn{3} = @(h,e)disp(&#039;Pan KeyPressFcn replacement&#039;);
            case &#039;Exploration.Zoom&#039;
                disp(&#039;Zoom on&#039;)
                [hManager.WindowListenerHandles.Enabled] = deal(false);
                fig.KeyPressFcn{3} = @(h,e)disp(&#039;Zoom KeyPressFcn replacement&#039;);                
            case &#039;Exploration.Datacursor&#039;
                disp(&#039;Zoom on&#039;)
                [hManager.WindowListenerHandles.Enabled] = deal(false);
                fig.KeyPressFcn{3} = @(h,e)disp(&#039;DataCursor KeyPressFcn replacement&#039;);
            otherwise
                disp(hManager.CurrentMode.Name)
        end
    end
end
&lt;/pre&gt;
]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-508323">Donato</a>.</p>
<p>OK, Been working on this again and found a solution which works in 2020a and 2020b. Below a working example which resets the KeyPressFcn for all ui-modes after activating them. It seems it is necessary to reset the 3rd KeyPressFcn, don&#8217;t ask me what the others are for &#8230;</p>
<pre lang="Matlab">
HV = 'off';
fig = figure('HandleVisibility',HV);
ax  = axes('Parent',fig, 'HandleVisibility',HV);
plot(rand(1,12),'k.-', 'Parent',ax)
    
hManager = uigetmodemanager(fig);
addlistener(hManager,'CurrentMode','PostSet',@MonitorModeChange);
    
function MonitorModeChange(varargin)
%hManager = uigetmodemanager(fig);
    if ~isempty(hManager.CurrentMode)
        switch hManager.CurrentMode.Name
            case 'Exploration.Brushing'
                disp('Brushing on')
                [hManager.WindowListenerHandles.Enabled] = deal(false);
                fig.KeyPressFcn{3} = @(h,e)disp('Brush KeyPressFcn replacement');
            case 'Exploration.Pan'
                disp('Pan on')
                [hManager.WindowListenerHandles.Enabled] = deal(false);
                fig.KeyPressFcn{3} = @(h,e)disp('Pan KeyPressFcn replacement');
            case 'Exploration.Zoom'
                disp('Zoom on')
                [hManager.WindowListenerHandles.Enabled] = deal(false);
                fig.KeyPressFcn{3} = @(h,e)disp('Zoom KeyPressFcn replacement');                
            case 'Exploration.Datacursor'
                disp('Zoom on')
                [hManager.WindowListenerHandles.Enabled] = deal(false);
                fig.KeyPressFcn{3} = @(h,e)disp('DataCursor KeyPressFcn replacement');
            otherwise
                disp(hManager.CurrentMode.Name)
        end
    end
end
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sebastian Hölz		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-509877</link>

		<dc:creator><![CDATA[Sebastian Hölz]]></dc:creator>
		<pubDate>Tue, 02 Feb 2021 12:16:15 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-509877</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-508323&quot;&gt;Donato&lt;/a&gt;.

I have not investigated this in detail, but I think one way to go in new versions of Matlab (&#062;2019b) might be to use listeners to suitable figure properties, e.g.
&lt;pre lang=&quot;matlab&quot;&gt;
fig = figure;
ax = axes;
ls = addlistener(fig,&#039;CurrentCharacter&#039;,&#039;PostSet&#039;,@(h,e)disp(e));
zoom on
&lt;/pre&gt;
This solves one problem, as the KeyPress is directed to the callback function as desired. However, a new problem is that the figure loses the focus since the KeyPress is also directed to the command window.
I have not found a quick way to solve this problem, but maybe somebody else does ...]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-508323">Donato</a>.</p>
<p>I have not investigated this in detail, but I think one way to go in new versions of Matlab (&gt;2019b) might be to use listeners to suitable figure properties, e.g.</p>
<pre lang="matlab">
fig = figure;
ax = axes;
ls = addlistener(fig,'CurrentCharacter','PostSet',@(h,e)disp(e));
zoom on
</pre>
<p>This solves one problem, as the KeyPress is directed to the callback function as desired. However, a new problem is that the figure loses the focus since the KeyPress is also directed to the command window.<br />
I have not found a quick way to solve this problem, but maybe somebody else does &#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Hannes		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-508839</link>

		<dc:creator><![CDATA[Hannes]]></dc:creator>
		<pubDate>Wed, 19 Aug 2020 11:05:38 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-508839</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-508323&quot;&gt;Donato&lt;/a&gt;.

It is also not working for me on R2019a Update 5. Best Hannes.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-508323">Donato</a>.</p>
<p>It is also not working for me on R2019a Update 5. Best Hannes.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Donato		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-508323</link>

		<dc:creator><![CDATA[Donato]]></dc:creator>
		<pubDate>Sat, 21 Mar 2020 18:12:41 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-508323</guid>

					<description><![CDATA[Hi Yair,
it seems that in Matlab R2019b this method doesn&#039;t work.
Have you some solutions?

Thanks.]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,<br />
it seems that in Matlab R2019b this method doesn&#8217;t work.<br />
Have you some solutions?</p>
<p>Thanks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Thommy		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-415223</link>

		<dc:creator><![CDATA[Thommy]]></dc:creator>
		<pubDate>Fri, 20 Oct 2017 07:15:09 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-415223</guid>

					<description><![CDATA[Thank you mate, I&#039;ve passed quite some time on that issue. You made my day !]]></description>
			<content:encoded><![CDATA[<p>Thank you mate, I&#8217;ve passed quite some time on that issue. You made my day !</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: David		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-385887</link>

		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Wed, 17 Aug 2016 15:11:39 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-385887</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-385877&quot;&gt;David&lt;/a&gt;.

I explored this a bit more and the problem is specific to the key input ctrl-z. Any other keystroke is passed to my callback, but ctrl-z is trapped and interpreted by the zoom&#039;s own callback. The question remains how do I override this behavior?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-385877">David</a>.</p>
<p>I explored this a bit more and the problem is specific to the key input ctrl-z. Any other keystroke is passed to my callback, but ctrl-z is trapped and interpreted by the zoom&#8217;s own callback. The question remains how do I override this behavior?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: David		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-385877</link>

		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Wed, 17 Aug 2016 13:34:05 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-385877</guid>

					<description><![CDATA[I&#039;m trying to apply this approach in the zoomIn toolbar callback:
&lt;pre lang=&quot;matlab&quot;&gt;
function zoomIn_OnCallback(hObject, eventdata, handles)
  [handles.mode_manager.WindowListenerHandles.Enabled] = deal(false);
  handles.theGui.WindowKeyPressFcn =  [];
  handles.theGui.KeyPressFcn = @theGui_KeyPressFcn;
end
&lt;/pre&gt;
where handles.mode_manager was set to uigetmodemanager in the GUIDE generated OpeningFcn. I can verify in the debugger that the call is executed and the callback is being assigned to theGui handle. The callback theGui_KeyPressFcn has the desired behavior when not in zoom mode, but in zoom mode it is not being called in spite of the above code. 

Obviously I&#039;ve missed something here, but I can&#039;t see what it is.
(I&#039;m not concerned about backwards compatibility, so I skipped the try/catch)]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to apply this approach in the zoomIn toolbar callback:</p>
<pre lang="matlab">
function zoomIn_OnCallback(hObject, eventdata, handles)
  [handles.mode_manager.WindowListenerHandles.Enabled] = deal(false);
  handles.theGui.WindowKeyPressFcn =  [];
  handles.theGui.KeyPressFcn = @theGui_KeyPressFcn;
end
</pre>
<p>where handles.mode_manager was set to uigetmodemanager in the GUIDE generated OpeningFcn. I can verify in the debugger that the call is executed and the callback is being assigned to theGui handle. The callback theGui_KeyPressFcn has the desired behavior when not in zoom mode, but in zoom mode it is not being called in spite of the above code. </p>
<p>Obviously I&#8217;ve missed something here, but I can&#8217;t see what it is.<br />
(I&#8217;m not concerned about backwards compatibility, so I skipped the try/catch)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: i3v		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-379143</link>

		<dc:creator><![CDATA[i3v]]></dc:creator>
		<pubDate>Sat, 04 Jun 2016 15:25:18 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-379143</guid>

					<description><![CDATA[Yair,
Thanks for the code!
Still, it looks like these few lines is not the only thing to keep in mind.
I was unable to find a complete, fully working example, so I&#039;ve decided to write my own. Hope it would be helpful for those who would try to to re-define these callbacks as well.
http://www.mathworks.com/matlabcentral/fileexchange/57496-i3v-figkeys]]></description>
			<content:encoded><![CDATA[<p>Yair,<br />
Thanks for the code!<br />
Still, it looks like these few lines is not the only thing to keep in mind.<br />
I was unable to find a complete, fully working example, so I&#8217;ve decided to write my own. Hope it would be helpful for those who would try to to re-define these callbacks as well.<br />
<a href="http://www.mathworks.com/matlabcentral/fileexchange/57496-i3v-figkeys" rel="nofollow ugc">http://www.mathworks.com/matlabcentral/fileexchange/57496-i3v-figkeys</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Maurizio		</title>
		<link>https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-369879</link>

		<dc:creator><![CDATA[Maurizio]]></dc:creator>
		<pubDate>Sun, 14 Feb 2016 15:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6043#comment-369879</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-369782&quot;&gt;Maurizio&lt;/a&gt;.

Oh, I see what you mean. I&#039;ll give that a try, thanks.
Meanwhile I fixed the problem with this line of code.

&lt;pre lang=&quot;matlab&quot;&gt;
set(handles.figure1, &#039;KeyPressFcn&#039;, ...
           @(hObject,eventdata)myGui(&#039;figure1_KeyPressFcn&#039;, hObject,eventdata,guidata(hObject)));
&lt;/pre&gt;
 I simply copied the anonymous function from the Property Inspector of figure1 in GUIDE.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/enabling-user-callbacks-during-zoom-pan#comment-369782">Maurizio</a>.</p>
<p>Oh, I see what you mean. I&#8217;ll give that a try, thanks.<br />
Meanwhile I fixed the problem with this line of code.</p>
<pre lang="matlab">
set(handles.figure1, 'KeyPressFcn', ...
           @(hObject,eventdata)myGui('figure1_KeyPressFcn', hObject,eventdata,guidata(hObject)));
</pre>
<p> I simply copied the anonymous function from the Property Inspector of figure1 in GUIDE.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
