3.2.0

Hooking setter in defineProperty()

Hey Alex,

Is there any way of hooking the setter generated by defineProperty() to executing some additional code other than setting the value of the property. I know I can write the setter/getter manually, just wondering whether there was a clever way.
LostInSpace
December 1,
I suggest (if you havent gotten past this, which I suspect you have), that you create custom methods of your control to set/get your new property without trying to modify the newly generated methods. Less room for failure. If you did find a way to modify the generated setter/getter then I would like to hear about it.

Thanks...
Jim Hunter (www.FriendsOfAW.com)
February 10,
Each generated setter includes raises two events - ...Changing and ...Changed, for example for text property of the cell model those are -

// before the change
onCellTextChanging(text, col, row);

//after the change
onCellTextChanged(text, col, row);

The events could be used to perform additional actions when a setter (for example, setCellText()) method is called. It is possible also to cancel assignment if non-zero value is returned from ...Changing() event handler.
Alex (ActiveWidgets)
February 13,
It would appear that this is true for controls, but not for models?
LostInSpace
February 14,
Sorry - allow me to clarify that previous post.

For a control, such as a AW.UI.Grid, if I define a model with properties, then setting values to the model properties raises the on...Changing and on...Changed events. This is what Alex (ActiveWidgets) said.

For an external mode, as might be used with a Grid, then the a property created with defineProperty() does not raises these events.
LostInSpace
February 14,

This topic is archived.

See also:


Back to support forum