Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

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 3

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 3

"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 3

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


Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
undocumented Darik 18 Oct, 2007 14:00:23
schemaprop Darik 18 Oct, 2007 14:00:23
listener Darik 18 Oct, 2007 14:00:23
propertypreset Darik 18 Oct, 2007 14:00:23
propertypostset Darik 18 Oct, 2007 14:00:23
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics