<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157947</link>
    <title>MATLAB Central Newsreader - Aborting a set in a PropertyPreSet listener callback</title>
    <description>Feed for thread: Aborting a set in a PropertyPreSet listener callback</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 18 Oct 2007 17:58:54 -0400</pubDate>
      <title>Aborting a set in a PropertyPreSet listener callback</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157947#397403</link>
      <author>Darik </author>
      <description>Is there a way to abort a requested SET call in a &lt;br&gt;
PropertyPreSet listener callback? &lt;br&gt;
&lt;br&gt;
schema.prop objects have an access flag called 'AbortSet' &lt;br&gt;
that would suggest this is possible, but I haven't found &lt;br&gt;
anything digging through Mathworks' code. &lt;br&gt;
&lt;br&gt;
I know I COULD create a corresponding PropertyPostSet &lt;br&gt;
listener to 'undo' whatever was done, but this gets pretty &lt;br&gt;
unwieldy with linked properties (i.e. setting the XLim &lt;br&gt;
property of an axes changes the XLimMode, XTick, etc.)</description>
    </item>
    <item>
      <pubDate>Thu, 18 Oct 2007 23:42:09 -0400</pubDate>
      <title>Re: Aborting a set in a PropertyPreSet listener callback</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157947#397438</link>
      <author>Yair Altman</author>
      <description>&quot;Darik &quot; &amp;lt;dgambleDEL@uwaterlooDEL.caDEL&amp;gt; wrote in message&lt;br&gt;
&amp;lt;ff86su$p1i$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Is there a way to abort a requested SET call in a &lt;br&gt;
&amp;gt; PropertyPreSet listener callback? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; schema.prop objects have an access flag called 'AbortSet' &lt;br&gt;
&amp;gt; that would suggest this is possible, but I haven't found &lt;br&gt;
&amp;gt; anything digging through Mathworks' code. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I know I COULD create a corresponding PropertyPostSet &lt;br&gt;
&amp;gt; listener to 'undo' whatever was done, but this gets pretty &lt;br&gt;
&amp;gt; unwieldy with linked properties (i.e. setting the XLim &lt;br&gt;
&amp;gt; property of an axes changes the XLimMode, XTick, etc.)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I never tried it myself, but you can try one of two ways:&lt;br&gt;
&lt;br&gt;
1) set the schema.prop's SetFunction to your own callback,&lt;br&gt;
in which you can abort or return the original value. Note&lt;br&gt;
that SetFunction is unsupported in Matlab 6, but is in 7&lt;br&gt;
(unsure about 6.5). See usage example in my uicomponent&lt;br&gt;
submission:&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14583&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14583&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
2) within your PropertyPreSet callback, retrieve the&lt;br&gt;
original value and use it to modify the suggestedValue back&lt;br&gt;
to the original value. This will effectively abort the&lt;br&gt;
property's modification.&lt;br&gt;
&lt;br&gt;
...or ask Mathworks how to use AbortSet (ha ha...)&lt;br&gt;
&lt;br&gt;
Yair Altman&lt;br&gt;
&lt;a href=&quot;http://ymasoftware.com&quot;&gt;http://ymasoftware.com&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Fri, 19 Oct 2007 15:21:48 -0400</pubDate>
      <title>Re: Aborting a set in a PropertyPreSet listener callback</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157947#397531</link>
      <author>Darik </author>
      <description>&quot;Yair Altman&quot; &amp;lt;altmanyDEL@gmailDEL.comDEL&amp;gt; wrote in message &lt;br&gt;
&amp;lt;ff8r0h$gdq$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I never tried it myself, but you can try one of two ways:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 1) set the schema.prop's SetFunction to your own callback,&lt;br&gt;
&amp;gt; in which you can abort or return the original value. Note&lt;br&gt;
&amp;gt; that SetFunction is unsupported in Matlab 6, but is in 7&lt;br&gt;
&amp;gt; (unsure about 6.5). See usage example in my uicomponent&lt;br&gt;
&amp;gt; submission:&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/loadFile&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/loadFile&lt;/a&gt;&lt;br&gt;
.do?objectId=14583&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Yeah, this would definitely be the easiest route, but &lt;br&gt;
unfortunately most of the interesting properties seem to be &lt;br&gt;
read-only. &lt;br&gt;
&lt;br&gt;
E.g.&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; p = findprop(handle(gca), 'XLim');&lt;br&gt;
&amp;gt;&amp;gt; p.SetFunction = @mySetFunction;&lt;br&gt;
&lt;br&gt;
Returns: &lt;br&gt;
&lt;br&gt;
??? The SetFunction for this property can not be modified.&lt;br&gt;
&lt;br&gt;
Any way around this?&lt;br&gt;
&lt;br&gt;
&amp;gt; 2) within your PropertyPreSet callback, retrieve the&lt;br&gt;
&amp;gt; original value and use it to modify the suggestedValue &lt;br&gt;
back&lt;br&gt;
&amp;gt; to the original value. This will effectively abort the&lt;br&gt;
&amp;gt; property's modification.&lt;br&gt;
&lt;br&gt;
This actually doesn't work, oddly enough. As far as I can &lt;br&gt;
tell, any set calls in the PropertyPreSet callback are &lt;br&gt;
overridden by the set call that triggered the listener &lt;br&gt;
callback in the first place. I can create a property to &lt;br&gt;
temporarily store the original value, which can then be &lt;br&gt;
replaced by a corresponding PropertyPostSet function, but &lt;br&gt;
as I said, this gets a bit hairy with multiple linked &lt;br&gt;
properties.&lt;br&gt;
&lt;br&gt;
&amp;gt; ...or ask Mathworks how to use AbortSet (ha ha...)&lt;br&gt;
&lt;br&gt;
Hah, I wish.</description>
    </item>
    <item>
      <pubDate>Tue, 22 Jun 2010 11:49:21 -0400</pubDate>
      <title>Re: Aborting a set in a PropertyPreSet listener callback</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157947#756498</link>
      <author>Yair Altman</author>
      <description>&quot;Darik &quot; &amp;lt;dgambleDEL@uwaterlooDEL.caDEL&amp;gt; wrote in message &amp;lt;ff86su$p1i$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Is there a way to abort a requested SET call in a &lt;br&gt;
&amp;gt; PropertyPreSet listener callback? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; schema.prop objects have an access flag called 'AbortSet' &lt;br&gt;
&amp;gt; that would suggest this is possible, but I haven't found &lt;br&gt;
&amp;gt; anything digging through Mathworks' code. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I know I COULD create a corresponding PropertyPostSet &lt;br&gt;
&amp;gt; listener to 'undo' whatever was done, but this gets pretty &lt;br&gt;
&amp;gt; unwieldy with linked properties (i.e. setting the XLim &lt;br&gt;
&amp;gt; property of an axes changes the XLimMode, XTick, etc.)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
As a service to the general public who might come across this thread, here is some new information:&lt;br&gt;
&lt;br&gt;
1. As noted by Darik, properties for existing objects (that have active instances) cannot be modified. Only newly-created user properties (using the schema.prop function) can be modified and have their meta-property SetFunction modified to some user callback that can intercept and modify the expected value.&lt;br&gt;
&lt;br&gt;
2. The meta-property AccessFlags.AbortSet is unrelated to the functionality of intercepting and modifying a set() modification. It just controls whether or not the data is actually re-set (and the callback is executed) when it is not really changed from its existing value. See &lt;a href=&quot;http://www.mathworks.com/access//helpdesk/help/techdoc/matlab_oop/brkik73.html#bry1hcf&quot;&gt;http://www.mathworks.com/access//helpdesk/help/techdoc/matlab_oop/brkik73.html#bry1hcf&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
3. The bottom line with regards to Darik's original question is that there is no simple solution. But at least we now know more of the details... &lt;br&gt;
&lt;br&gt;
Yair Altman &lt;br&gt;
&lt;a href=&quot;http://UndocumentedMatlab.com&quot;&gt;http://UndocumentedMatlab.com&lt;/a&gt; </description>
    </item>
  </channel>
</rss>

