Path: news.mathworks.com!not-for-mail
From: "Darik " <dgambleDEL@uwaterlooDEL.caDEL>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Aborting a set in a PropertyPreSet listener callback
Date: Fri, 19 Oct 2007 15:21:48 +0000 (UTC)
Organization: Waterloo
Lines: 50
Message-ID: <ffai2c$7dg$1@fred.mathworks.com>
References: <ff86su$p1i$1@fred.mathworks.com> <ff8r0h$gdq$1@fred.mathworks.com>
Reply-To: "Darik " <dgambleDEL@uwaterlooDEL.caDEL>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1192807308 7600 172.30.248.37 (19 Oct 2007 15:21:48 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 19 Oct 2007 15:21:48 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 895526
Xref: news.mathworks.com comp.soft-sys.matlab:433757


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