<?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: Property value change listeners	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/property-value-change-listeners/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/property-value-change-listeners?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=property-value-change-listeners</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Sun, 22 Sep 2024 06:49:28 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Enrico Segre		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-525393</link>

		<dc:creator><![CDATA[Enrico Segre]]></dc:creator>
		<pubDate>Sun, 22 Sep 2024 06:49:28 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-525393</guid>

					<description><![CDATA[Actually, here you&#039;re talking, AFAIU, only of callbacks fired by events generated in Matlab graphic windows. I argue that they a little special by themselves, and unfortunately, they are not the only construct for which matlab uses the term &quot;callback&quot;.

For what I&#039;ve perused in my coding, there are also:

- timer callbacks
- instrument callbacks
- Observable property class callbacks

To my understanding, from the user point of view, graphical callbacks are the only ones which can be declared, using matlab language alone, as &lt;i&gt;interruptible&lt;/i&gt; (or non-). The fact that a callback function is or not interruptible has far reaching consequences, for the use I have been making of them.

Moreover, imho, &quot;callbacks&quot; associated to Pre/Post set/get listeners of properties of ordinary classes, are not even &quot;callbacks&quot;, in the sense that there is no external, asynchronous event which fires them; they are more like a syntactic sugar, for function calls which are inserted by the compiler whenever property assignments are encountered in the program flow. Not surprisingly to me, they in fact the only ones that turn to be &quot;interruptible&quot;.

As a part of a large codebase in a big [project, I have documented my conclusions in 
https://github.com/EastEriq/LAST_Messaging/blob/gledmagicwater/doc/Exploiting_Callbacks.md
I wonder if you have the time to skim through it and to add your insight....]]></description>
			<content:encoded><![CDATA[<p>Actually, here you&#8217;re talking, AFAIU, only of callbacks fired by events generated in Matlab graphic windows. I argue that they a little special by themselves, and unfortunately, they are not the only construct for which matlab uses the term &#8220;callback&#8221;.</p>
<p>For what I&#8217;ve perused in my coding, there are also:</p>
<p>&#8211; timer callbacks<br />
&#8211; instrument callbacks<br />
&#8211; Observable property class callbacks</p>
<p>To my understanding, from the user point of view, graphical callbacks are the only ones which can be declared, using matlab language alone, as <i>interruptible</i> (or non-). The fact that a callback function is or not interruptible has far reaching consequences, for the use I have been making of them.</p>
<p>Moreover, imho, &#8220;callbacks&#8221; associated to Pre/Post set/get listeners of properties of ordinary classes, are not even &#8220;callbacks&#8221;, in the sense that there is no external, asynchronous event which fires them; they are more like a syntactic sugar, for function calls which are inserted by the compiler whenever property assignments are encountered in the program flow. Not surprisingly to me, they in fact the only ones that turn to be &#8220;interruptible&#8221;.</p>
<p>As a part of a large codebase in a big [project, I have documented my conclusions in<br />
<a href="https://github.com/EastEriq/LAST_Messaging/blob/gledmagicwater/doc/Exploiting_Callbacks.md" rel="nofollow ugc">https://github.com/EastEriq/LAST_Messaging/blob/gledmagicwater/doc/Exploiting_Callbacks.md</a><br />
I wonder if you have the time to skim through it and to add your insight&#8230;.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Rohit		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-458860</link>

		<dc:creator><![CDATA[Rohit]]></dc:creator>
		<pubDate>Tue, 29 Jan 2019 11:56:21 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-458860</guid>

					<description><![CDATA[@Yair,
The reason to attach a listener is that, we have a Matlab tool in which &quot;Text control&quot; is written programmatically at 1000&#039;s places. Now, I have introduced a &quot;Message Log Panel&quot; in which I want to put the same messages that were written to &quot;Text control&quot;. Either I go to 1000&#039;s places and place my code to write messages to &quot;Log Panel&quot; or attach a listener to &quot;text control&quot; such that whenever any messages is written to &quot;text control&quot;, it automatically comes to the &quot;Log panel&quot; as well.

BTW, thanks , your suggestion worked..!]]></description>
			<content:encoded><![CDATA[<p>@Yair,<br />
The reason to attach a listener is that, we have a Matlab tool in which &#8220;Text control&#8221; is written programmatically at 1000&#8217;s places. Now, I have introduced a &#8220;Message Log Panel&#8221; in which I want to put the same messages that were written to &#8220;Text control&#8221;. Either I go to 1000&#8217;s places and place my code to write messages to &#8220;Log Panel&#8221; or attach a listener to &#8220;text control&#8221; such that whenever any messages is written to &#8220;text control&#8221;, it automatically comes to the &#8220;Log panel&#8221; as well.</p>
<p>BTW, thanks , your suggestion worked..!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-458843</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 29 Jan 2019 10:37:38 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-458843</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-458801&quot;&gt;rohit&lt;/a&gt;.

@Rohit - yes you can, but I have no idea why you&#039;d want to do this. After all, text controls are typically changed programmatically (not interactively) so you can call your requested functionality whenever you modify the text. 

In any case, here&#039;s how you can attach the requested callback:
&lt;pre lang=&quot;matlab&quot;&gt;
hText = uicontrol(&#039;Style&#039;,&#039;text&#039;, ...);
hProp = findprop(hText,&#039;String&#039;);
callback = @(h,e) disp(hText.String);  % your callback function handle
hListener = addlistener(hText, hProp, &#039;PostSet&#039;, callback);
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-458801">rohit</a>.</p>
<p>@Rohit &#8211; yes you can, but I have no idea why you&#8217;d want to do this. After all, text controls are typically changed programmatically (not interactively) so you can call your requested functionality whenever you modify the text. </p>
<p>In any case, here&#8217;s how you can attach the requested callback:</p>
<pre lang="matlab">
hText = uicontrol('Style','text', ...);
hProp = findprop(hText,'String');
callback = @(h,e) disp(hText.String);  % your callback function handle
hListener = addlistener(hText, hProp, 'PostSet', callback);
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: rohit		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-458801</link>

		<dc:creator><![CDATA[rohit]]></dc:creator>
		<pubDate>Tue, 29 Jan 2019 07:07:20 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-458801</guid>

					<description><![CDATA[Yair,

Can we attach a listener to &quot;text&quot; uicontrol ? So that whenever &quot;String&quot; property of &quot;text&quot; control changes, we can detect it ?]]></description>
			<content:encoded><![CDATA[<p>Yair,</p>
<p>Can we attach a listener to &#8220;text&#8221; uicontrol ? So that whenever &#8220;String&#8221; property of &#8220;text&#8221; control changes, we can detect it ?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-448735</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 24 Oct 2018 10:30:32 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-448735</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-448728&quot;&gt;Ofer Saferman&lt;/a&gt;.

@Ofer - you need to set the &lt;code&gt;GetObservable&lt;/code&gt; meta-attribute to enable listening to &lt;code&gt;PreGet/PostGet&lt;/code&gt; events, and similarly set &lt;code&gt;SetObservable&lt;/code&gt; for &lt;code&gt;PreSet/PostSet&lt;/code&gt; events. For example:
&lt;pre lang=&quot;matlab&quot;&gt;
hObj = gcf;  % current figure (can be any handle)
hProp = addprop(hObj,&#039;Yair&#039;);
hProp.SetObservable = true;
addlistener(hObj,&#039;Yair&#039;,&#039;PostSet&#039;,@(h,e)disp(123));
hObj.Yair = 2;  % &quot;123&quot; will be displayed in the Matlab console
&lt;/pre&gt;

If you forget to set the &lt;code&gt;GetObservable/SetObservable&lt;/code&gt; meta-attribute, you will receive a run-time error when you try to call &lt;i&gt;&lt;b&gt;addlistener&lt;/b&gt;&lt;/i&gt;:
&lt;pre lang=&quot;text&quot;&gt;
Error using matlab.ui.Figure/addlistener
While adding a PostSet listener, property &#039;Yair&#039; in class &#039;matlab.ui.Figure&#039; is not defined to be SetObservable. 
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-448728">Ofer Saferman</a>.</p>
<p>@Ofer &#8211; you need to set the <code>GetObservable</code> meta-attribute to enable listening to <code>PreGet/PostGet</code> events, and similarly set <code>SetObservable</code> for <code>PreSet/PostSet</code> events. For example:</p>
<pre lang="matlab">
hObj = gcf;  % current figure (can be any handle)
hProp = addprop(hObj,'Yair');
hProp.SetObservable = true;
addlistener(hObj,'Yair','PostSet',@(h,e)disp(123));
hObj.Yair = 2;  % "123" will be displayed in the Matlab console
</pre>
<p>If you forget to set the <code>GetObservable/SetObservable</code> meta-attribute, you will receive a run-time error when you try to call <i><b>addlistener</b></i>:</p>
<pre lang="text">
Error using matlab.ui.Figure/addlistener
While adding a PostSet listener, property 'Yair' in class 'matlab.ui.Figure' is not defined to be SetObservable. 
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ofer Saferman		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-448728</link>

		<dc:creator><![CDATA[Ofer Saferman]]></dc:creator>
		<pubDate>Wed, 24 Oct 2018 09:58:02 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-448728</guid>

					<description><![CDATA[How do you know which properties are observable?
Can you in general listen to your own added properties using setappdata? How to make them observable?
Thanks]]></description>
			<content:encoded><![CDATA[<p>How do you know which properties are observable?<br />
Can you in general listen to your own added properties using setappdata? How to make them observable?<br />
Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Collin Pecora		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-389075</link>

		<dc:creator><![CDATA[Collin Pecora]]></dc:creator>
		<pubDate>Fri, 23 Sep 2016 21:58:20 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-389075</guid>

					<description><![CDATA[Is there a way to listen for property changes of &#039;pure&#039; java objects created in matlab?

Specificaly, I would like to listen to the value property of a jFormattedTextField as suggested by the javadocs]]></description>
			<content:encoded><![CDATA[<p>Is there a way to listen for property changes of &#8216;pure&#8217; java objects created in matlab?</p>
<p>Specificaly, I would like to listen to the value property of a jFormattedTextField as suggested by the javadocs</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Julian		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-374187</link>

		<dc:creator><![CDATA[Julian]]></dc:creator>
		<pubDate>Mon, 11 Apr 2016 07:31:49 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-374187</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-331292&quot;&gt;John&lt;/a&gt;.

Hi John,

you can listen to a &#039;SizeChanged&#039; Property in HG2 handling
&lt;pre lang=&quot;matlab&quot;&gt;
h = addlistener(gcf,&#039;SizeChanged&#039;,@func);
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-331292">John</a>.</p>
<p>Hi John,</p>
<p>you can listen to a &#8216;SizeChanged&#8217; Property in HG2 handling</p>
<pre lang="matlab">
h = addlistener(gcf,'SizeChanged',@func);
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Erik		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-348826</link>

		<dc:creator><![CDATA[Erik]]></dc:creator>
		<pubDate>Mon, 04 May 2015 18:58:05 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-348826</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-331292&quot;&gt;John&lt;/a&gt;.

@John - Not the most elegant solution - but you could try to listen for an Event that always executes when position is changed. Using Matlab 2015a; for example, to determine potential event names for an axes position change:

&lt;pre lang=&quot;matlab&quot;&gt; 
hAxes = axes;
md = ?matlab.graphics.axis.Axes;
eventNames = {md.EventList.Name};
for iEvent = 1:numel(eventNames)
    addlistener(hAxes, eventNames{iEvent}, @(~,~) disp(eventNames{iEvent}));
end
&lt;/pre&gt;

And then change your axes position in various manners to see what Events occur. My very-quick testing indicates Events {&#039;MarkedDirty&#039;, &#039;LocationChanged&#039;, &#039;SizeChanged&#039;, &#039;MarkedClean&#039;} are called in that order.

Keep in mind some Events {&#039;MarkedDirty&#039;, &#039;MarkedClean&#039;} are called for all sorts of (non-position related) reasons.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-331292">John</a>.</p>
<p>@John &#8211; Not the most elegant solution &#8211; but you could try to listen for an Event that always executes when position is changed. Using Matlab 2015a; for example, to determine potential event names for an axes position change:</p>
<pre lang="matlab"> 
hAxes = axes;
md = ?matlab.graphics.axis.Axes;
eventNames = {md.EventList.Name};
for iEvent = 1:numel(eventNames)
    addlistener(hAxes, eventNames{iEvent}, @(~,~) disp(eventNames{iEvent}));
end
</pre>
<p>And then change your axes position in various manners to see what Events occur. My very-quick testing indicates Events {&#8216;MarkedDirty&#8217;, &#8216;LocationChanged&#8217;, &#8216;SizeChanged&#8217;, &#8216;MarkedClean&#8217;} are called in that order.</p>
<p>Keep in mind some Events {&#8216;MarkedDirty&#8217;, &#8216;MarkedClean&#8217;} are called for all sorts of (non-position related) reasons.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-331293</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 10 Sep 2014 17:17:29 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4955#comment-331293</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-331292&quot;&gt;John&lt;/a&gt;.

@John - I do not know of a way to listen to non-observable properties. Perhaps there is a way, but I don&#039;t know it.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/property-value-change-listeners#comment-331292">John</a>.</p>
<p>@John &#8211; I do not know of a way to listen to non-observable properties. Perhaps there is a way, but I don&#8217;t know it.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
