Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Aborting a set in a PropertyPreSet listener callback

Subject: Aborting a set in a PropertyPreSet listener callback

From: Darik

Date: 18 Oct, 2007 17:58:54

Message: 1 of 4

Is there a way to abort a requested SET call in a
PropertyPreSet listener callback?

schema.prop objects have an access flag called 'AbortSet'
that would suggest this is possible, but I haven't found
anything digging through Mathworks' code.

I know I COULD create a corresponding PropertyPostSet
listener to 'undo' whatever was done, but this gets pretty
unwieldy with linked properties (i.e. setting the XLim
property of an axes changes the XLimMode, XTick, etc.)

Subject: Aborting a set in a PropertyPreSet listener callback

From: Yair Altman

Date: 18 Oct, 2007 23:42:09

Message: 2 of 4

"Darik " <dgambleDEL@uwaterlooDEL.caDEL> wrote in message
<ff86su$p1i$1@fred.mathworks.com>...
> Is there a way to abort a requested SET call in a
> PropertyPreSet listener callback?
>
> schema.prop objects have an access flag called 'AbortSet'
> that would suggest this is possible, but I haven't found
> anything digging through Mathworks' code.
>
> I know I COULD create a corresponding PropertyPostSet
> listener to 'undo' whatever was done, but this gets pretty
> unwieldy with linked properties (i.e. setting the XLim
> property of an axes changes the XLimMode, XTick, etc.)


I never tried it myself, but you can try one of two ways:

1) set the schema.prop's SetFunction to your own callback,
in which you can abort or return the original value. Note
that SetFunction is unsupported in Matlab 6, but is in 7
(unsure about 6.5). See usage example in my uicomponent
submission:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14583

2) within your PropertyPreSet callback, retrieve the
original value and use it to modify the suggestedValue back
to the original value. This will effectively abort the
property's modification.

...or ask Mathworks how to use AbortSet (ha ha...)

Yair Altman
http://ymasoftware.com

Subject: Aborting a set in a PropertyPreSet listener callback

From: Darik

Date: 19 Oct, 2007 15:21:48

Message: 3 of 4

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<ff8r0h$gdq$1@fred.mathworks.com>...
>
> I never tried it myself, but you can try one of two ways:
>
> 1) set the schema.prop's SetFunction to your own callback,
> in which you can abort or return the original value. Note
> that SetFunction is unsupported in Matlab 6, but is in 7
> (unsure about 6.5). See usage example in my uicomponent
> submission:
>
http://www.mathworks.com/matlabcentral/fileexchange/loadFile
.do?objectId=14583
>

Yeah, this would definitely be the easiest route, but
unfortunately most of the interesting properties seem to be
read-only.

E.g.

>> p = findprop(handle(gca), 'XLim');
>> p.SetFunction = @mySetFunction;

Returns:

??? The SetFunction for this property can not be modified.

Any way around this?

> 2) within your PropertyPreSet callback, retrieve the
> original value and use it to modify the suggestedValue
back
> to the original value. This will effectively abort the
> property's modification.

This actually doesn't work, oddly enough. As far as I can
tell, any set calls in the PropertyPreSet callback are
overridden by the set call that triggered the listener
callback in the first place. I can create a property to
temporarily store the original value, which can then be
replaced by a corresponding PropertyPostSet function, but
as I said, this gets a bit hairy with multiple linked
properties.

> ...or ask Mathworks how to use AbortSet (ha ha...)

Hah, I wish.

Subject: Aborting a set in a PropertyPreSet listener callback

From: Yair Altman

Date: 22 Jun, 2010 11:49:21

Message: 4 of 4

"Darik " <dgambleDEL@uwaterlooDEL.caDEL> wrote in message <ff86su$p1i$1@fred.mathworks.com>...
> Is there a way to abort a requested SET call in a
> PropertyPreSet listener callback?
>
> schema.prop objects have an access flag called 'AbortSet'
> that would suggest this is possible, but I haven't found
> anything digging through Mathworks' code.
>
> I know I COULD create a corresponding PropertyPostSet
> listener to 'undo' whatever was done, but this gets pretty
> unwieldy with linked properties (i.e. setting the XLim
> property of an axes changes the XLimMode, XTick, etc.)


As a service to the general public who might come across this thread, here is some new information:

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.

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 http://www.mathworks.com/access//helpdesk/help/techdoc/matlab_oop/brkik73.html#bry1hcf

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...

Yair Altman
http://UndocumentedMatlab.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us