Forum > Designer
How to mark a collection property as modified after some items changed
(1/1)
alpine:
I have a component with ControlStyle + [csDesignInteractive] and when an item changed via mouse input (into the Designer), I would like the whole component to be marked as such.
I have no idea how to do it, advice please.
EDIT: To be more specific: the component is a map viewer and when a point, which belongs to a track, was dragged with a mouse, then the designer must be notified for the change. That is not the usual way to change a property (e.g. via TPropertyEditor) so it is the notify method
Thaddy:
Components, both design time and runtime derive from Tpersistent and that implements IFPObserver and IFPObserved.a.k.a. observer pattern. That can be used in your situation.
For example a TCollection or a TStringlist implement it as standard.
Michael wrote a very good article on objervers and mediaters
https://www.freepascal.org/~michael/articles/cdcover/cdcover.pdf
the sources are here:
https://www.freepascal.org/~michael/articles/cdcover/cdcover.zip
The unit from that project you are most interested in is the unit lclmediators.
alpine:
Thank you for the reply!
I'm aware of the observer pattern and the Michael's article, but my problem is actually how to inform the IDE for the property change.
On the 1-st attached picture, when you change the Latitude property, the save button (blue diskette) lit immediately, which means the TFloatPropertyEditor made his job to propagate the change up to the designer top level.
On the 2-nd picture, when you drag a point interactively, the save button stays gray, the Latitude isn't modified by means of TPropertyEditor and there must be a way to inform the designer that a property was changed. At that point I'm lacking the knowledge how to do it. Documentation on the matter is scarce or I just couldn't find it.
wp:
Not sure, but it seems to me that you must override the collection property editor for the trackpoints to get access to the Modified method. Try to study the code in ideintf/propedits - hard stuff, I know...
alpine:
--- Quote from: wp on July 08, 2024, 03:12:12 pm ---Not sure, but it seems to me that you must override the collection property editor for the trackpoints to get access to the Modified method. Try to study the code in ideintf/propedits - hard stuff, I know...
--- End quote ---
After lot of trials and errors with LazIDEIntf/PropEdits/ComponentEditors, etc., finally I have "assembled" kind of MapView point editor for the IDE. Not sure that it will be very convenient nor useful but at least it's runtime part (TMapEditMark, TMapEditorList) will do. The commit is r9385.
I'll be happy on any feedback.
Navigation
[0] Message Index