<?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: Undocumented HG2 graphics events	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=undocumented-hg2-graphics-events</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Fri, 13 Dec 2024 11:14:57 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>
		By: Adam D Danz		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-511010</link>

		<dc:creator><![CDATA[Adam D Danz]]></dc:creator>
		<pubDate>Thu, 03 Jun 2021 17:57:22 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-511010</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-511009&quot;&gt;Adam D Danz&lt;/a&gt;.

Opps.... I was using the wrong syntax: &lt;code&gt;MarkedClean&lt;/code&gt; is an EventName and I was accidentally treating it as a PropertyName.  Also, ignore the &quot;MarkedDirty&quot; reference in the error message which was in response to a different version of the listener. #NewbieMistake

The first syntax below is the correct one to use with &lt;code&gt;MarkedClean&lt;/code&gt;, as Yair demonstrated in this blog post.  

&lt;pre lang=&quot;matlab&quot;&gt;
el = addlistener(hSource, EventName, callback)  
el = addlistener(hSource, PropertyName, EventName, callback)
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-511009">Adam D Danz</a>.</p>
<p>Opps&#8230;. I was using the wrong syntax: <code>MarkedClean</code> is an EventName and I was accidentally treating it as a PropertyName.  Also, ignore the &#8220;MarkedDirty&#8221; reference in the error message which was in response to a different version of the listener. #NewbieMistake</p>
<p>The first syntax below is the correct one to use with <code>MarkedClean</code>, as Yair demonstrated in this blog post.  </p>
<pre lang="matlab">
el = addlistener(hSource, EventName, callback)  
el = addlistener(hSource, PropertyName, EventName, callback)
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Adam D Danz		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-511009</link>

		<dc:creator><![CDATA[Adam D Danz]]></dc:creator>
		<pubDate>Thu, 03 Jun 2021 16:44:33 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-511009</guid>

					<description><![CDATA[Yair, thanks for your unmatched contributions to exploring Matlab under the hood. 

I noticed that listeners responding to MarkedClean in geoaxes throw an error even though MarkedClean appears to have public ListenAccess. 

&lt;pre lang=&quot;matlab&quot;&gt;
ax = geoaxes(&#039;basemap&#039;,&#039;satellite&#039;);
MC = metaclass(ax);
E = MC.EventList;
E(10)

 GraphicsMetaEvent with properties:

    HasCallbackProperty: 0
                   Name: &#039;MarkedClean&#039;
            Description: &#039;description&#039;
    DetailedDescription: &#039;detailed description&#039;
                 Hidden: 1
           NotifyAccess: &#039;public&#039;
           ListenAccess: &#039;public&#039;  &#060;--------
          DefiningClass: [1×1 matlab.graphics.internal.GraphicsMetaClass]
&lt;/pre&gt;

But when assigning a listener to geoaxes, 

&lt;pre lang=&quot;matlab&quot;&gt;
addlistener(ax,&#039;MarkedClean&#039;, ...
    &#039;PostSet&#039;, @(a,b)myFunc(a,b));

Error using matlab.graphics.axis.GeographicAxes/addlistener
The name &#039;MarkedDirty&#039; is not an accessible property for an instance of class &#039;matlab.graphics.axis.GeographicAxes&#039;.
&lt;/pre&gt;

I&#039;ve used this type of listener in other axes without problem but I don&#039;t understand what&#039;s blocking it with geoaxes.]]></description>
			<content:encoded><![CDATA[<p>Yair, thanks for your unmatched contributions to exploring Matlab under the hood. </p>
<p>I noticed that listeners responding to MarkedClean in geoaxes throw an error even though MarkedClean appears to have public ListenAccess. </p>
<pre lang="matlab">
ax = geoaxes('basemap','satellite');
MC = metaclass(ax);
E = MC.EventList;
E(10)

 GraphicsMetaEvent with properties:

    HasCallbackProperty: 0
                   Name: 'MarkedClean'
            Description: 'description'
    DetailedDescription: 'detailed description'
                 Hidden: 1
           NotifyAccess: 'public'
           ListenAccess: 'public'  &lt;--------
          DefiningClass: [1×1 matlab.graphics.internal.GraphicsMetaClass]
</pre>
<p>But when assigning a listener to geoaxes, </p>
<pre lang="matlab">
addlistener(ax,'MarkedClean', ...
    'PostSet', @(a,b)myFunc(a,b));

Error using matlab.graphics.axis.GeographicAxes/addlistener
The name 'MarkedDirty' is not an accessible property for an instance of class 'matlab.graphics.axis.GeographicAxes'.
</pre>
<p>I&#8217;ve used this type of listener in other axes without problem but I don&#8217;t understand what&#8217;s blocking it with geoaxes.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-510786</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Mon, 17 May 2021 20:15:27 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-510786</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-510784&quot;&gt;Tucker Downs&lt;/a&gt;.

@Tucker - AFAIK &lt;code&gt;markedClean&lt;/code&gt; still works even in the very latest release. In recent years MathWorks added a few documented hooks for trapping axes updates etc., but the &lt;code&gt;markedClean&lt;/code&gt; event still seems to be a general common mechanism.
If and when you have some information on the transforms, then please let me know.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-510784">Tucker Downs</a>.</p>
<p>@Tucker &#8211; AFAIK <code>markedClean</code> still works even in the very latest release. In recent years MathWorks added a few documented hooks for trapping axes updates etc., but the <code>markedClean</code> event still seems to be a general common mechanism.<br />
If and when you have some information on the transforms, then please let me know.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Tucker Downs		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-510784</link>

		<dc:creator><![CDATA[Tucker Downs]]></dc:creator>
		<pubDate>Mon, 17 May 2021 04:21:27 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-510784</guid>

					<description><![CDATA[Hi Yair, 

Is &quot;markedClean&quot; still your recommendation for wanting to redraw graphics primitive like objects? I&#039;m working on trying to make some native-like graphics objects and need to know when to redraw. 

Also, are you still looking for window transforms / data2pixel and its inverse? I have some info that you might find helpful. Will be posting code soon. 

-Tucker]]></description>
			<content:encoded><![CDATA[<p>Hi Yair, </p>
<p>Is &#8220;markedClean&#8221; still your recommendation for wanting to redraw graphics primitive like objects? I&#8217;m working on trying to make some native-like graphics objects and need to know when to redraw. </p>
<p>Also, are you still looking for window transforms / data2pixel and its inverse? I have some info that you might find helpful. Will be posting code soon. </p>
<p>-Tucker</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nick		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392373</link>

		<dc:creator><![CDATA[Nick]]></dc:creator>
		<pubDate>Thu, 03 Nov 2016 18:05:10 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-392373</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392367&quot;&gt;Yair Altman&lt;/a&gt;.

Yair - It looks like setting the Axes &#039;NextPlot&#039; property to &#039;add&#039; may prevent the resetting of HitTest. There is more behavior to investigate, but at least I seem to be on some kind of path. Thank you again]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392367">Yair Altman</a>.</p>
<p>Yair &#8211; It looks like setting the Axes &#8216;NextPlot&#8217; property to &#8216;add&#8217; may prevent the resetting of HitTest. There is more behavior to investigate, but at least I seem to be on some kind of path. Thank you again</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392367</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 03 Nov 2016 17:07:09 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-392367</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392364&quot;&gt;Nick&lt;/a&gt;.

@Nick - this is a &quot;known&quot; undocumented side-effect of using the high-level plotting functions (such as &lt;i&gt;&lt;b&gt;plot&lt;/b&gt;&lt;/i&gt;), which reset several axes properties including &lt;b&gt;HitTest&lt;/b&gt; and &lt;b&gt;Tag&lt;/b&gt;. In contrast, the low-level plotting functions (such as &lt;i&gt;&lt;b&gt;line&lt;/b&gt;&lt;/i&gt;) do not reset these properties.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392364">Nick</a>.</p>
<p>@Nick &#8211; this is a &#8220;known&#8221; undocumented side-effect of using the high-level plotting functions (such as <i><b>plot</b></i>), which reset several axes properties including <b>HitTest</b> and <b>Tag</b>. In contrast, the low-level plotting functions (such as <i><b>line</b></i>) do not reset these properties.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nick		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392364</link>

		<dc:creator><![CDATA[Nick]]></dc:creator>
		<pubDate>Thu, 03 Nov 2016 16:48:47 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-392364</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392280&quot;&gt;Nick&lt;/a&gt;.

I just learned a fun fact: plotting to an axes object who&#039;s HitTest property is set to &#039;off&#039; appears to reset HitTest to &#039;on&#039;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392280">Nick</a>.</p>
<p>I just learned a fun fact: plotting to an axes object who&#8217;s HitTest property is set to &#8216;off&#8217; appears to reset HitTest to &#8216;on&#8217;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nick		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392350</link>

		<dc:creator><![CDATA[Nick]]></dc:creator>
		<pubDate>Thu, 03 Nov 2016 13:25:42 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-392350</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392280&quot;&gt;Nick&lt;/a&gt;.

You are my hero - thank you for this invaluable resource. And thank you for pointing me to an (embarrassed) *documented* feature.

Cheers!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392280">Nick</a>.</p>
<p>You are my hero &#8211; thank you for this invaluable resource. And thank you for pointing me to an (embarrassed) *documented* feature.</p>
<p>Cheers!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392317</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 03 Nov 2016 06:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-392317</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392280&quot;&gt;Nick&lt;/a&gt;.

@Nick - 
&lt;pre lang=&quot;matlab&quot;&gt;set(gca,&#039;HitTest&#039;,&#039;off&#039;)&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392280">Nick</a>.</p>
<p>@Nick &#8211; </p>
<pre lang="matlab">set(gca,'HitTest','off')</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nick		</title>
		<link>https://undocumentedmatlab.com/articles/undocumented-hg2-graphics-events#comment-392280</link>

		<dc:creator><![CDATA[Nick]]></dc:creator>
		<pubDate>Wed, 02 Nov 2016 21:40:52 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5806#comment-392280</guid>

					<description><![CDATA[I&#039;ve been trying to find a way to prevent our users from deleting axes when they are deleting annotations. (This happens way more than I expected, and it is a major source of frustration). I thought it&#039;d be easy to find an event or callback to hook into and pop up a dialog, but it&#039;s proven fairly difficult for me to crack.

I thought maybe I could set a listener for ObjectBeingDestroyed, but it fires after the object is gone (or there&#039;s a synch issue).

Is there some kind of ObjectAboutToBeDestroyed or DestroyObjectRequest thats double-secret-undocumented?

Any thoughts as to how I can hook into this behavior (or as a welcomed alternative, turn off the ability to delete axes with the keyboard - I mean seriously, why is that even a thing?)

&lt;pre lang=&quot;matlab&quot;&gt;
function testAxesDelete
    hs = struct(&#039;fig&#039;, figure);
    hs.fig.MenuBar = &#039;none&#039;;
    hs.fig.ToolBar = &#039;figure&#039;;
    hs.fig.KeyPressFcn = @myKeyCallback;
    
    hs.ax = axes;
    hs.line = plot([0 0], [-1 1]);

    hs.ax.DeleteFcn = @myDeleteCallback;
    hs.ax.ButtonDownFcn = @myButtonCallback;
    
    addlistener(hs.ax, &#039;ObjectBeingDestroyed&#039;, @obdCallback);    
end

function myKeyCallback(hobj, event, varargin)
    disp(&#039;Pressed a key on figure!&#039;);
    disp(&#039;Axes still is deleted if you press delete with the axis selected&#039;);
    disp(&#039;Axis is deleted prior to executing this function&#039;)
    keyboard
end

function myDeleteCallback(hobj, event, varargin)
    disp(&#039;Deleting axes!&#039;);
    disp(&#039;Axis is deleted prior to executing this function&#039;)
    keyboard
end

function myButtonCallback(hobj, event, varargin)
    disp(&#039;Does not intercept delete key&#039;);
    keyboard
end

function obdCallback(hobj, event, varargin)
    disp(&#039;Object being destroyed callback&#039;);
    disp(&#039;this happens *after* the axes have been deleted &#039;);
    keyboard
end
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying to find a way to prevent our users from deleting axes when they are deleting annotations. (This happens way more than I expected, and it is a major source of frustration). I thought it&#8217;d be easy to find an event or callback to hook into and pop up a dialog, but it&#8217;s proven fairly difficult for me to crack.</p>
<p>I thought maybe I could set a listener for ObjectBeingDestroyed, but it fires after the object is gone (or there&#8217;s a synch issue).</p>
<p>Is there some kind of ObjectAboutToBeDestroyed or DestroyObjectRequest thats double-secret-undocumented?</p>
<p>Any thoughts as to how I can hook into this behavior (or as a welcomed alternative, turn off the ability to delete axes with the keyboard &#8211; I mean seriously, why is that even a thing?)</p>
<pre lang="matlab">
function testAxesDelete
    hs = struct('fig', figure);
    hs.fig.MenuBar = 'none';
    hs.fig.ToolBar = 'figure';
    hs.fig.KeyPressFcn = @myKeyCallback;
    
    hs.ax = axes;
    hs.line = plot([0 0], [-1 1]);

    hs.ax.DeleteFcn = @myDeleteCallback;
    hs.ax.ButtonDownFcn = @myButtonCallback;
    
    addlistener(hs.ax, 'ObjectBeingDestroyed', @obdCallback);    
end

function myKeyCallback(hobj, event, varargin)
    disp('Pressed a key on figure!');
    disp('Axes still is deleted if you press delete with the axis selected');
    disp('Axis is deleted prior to executing this function')
    keyboard
end

function myDeleteCallback(hobj, event, varargin)
    disp('Deleting axes!');
    disp('Axis is deleted prior to executing this function')
    keyboard
end

function myButtonCallback(hobj, event, varargin)
    disp('Does not intercept delete key');
    keyboard
end

function obdCallback(hobj, event, varargin)
    disp('Object being destroyed callback');
    disp('this happens *after* the axes have been deleted ');
    keyboard
end
</pre>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
