Recent

Author Topic: How to mark a collection property as modified after some items changed  (Read 1126 times)

alpine

  • Hero Member
  • *****
  • Posts: 1239
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
« Last Edit: July 08, 2024, 12:18:30 am by alpine »
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Thaddy

  • Hero Member
  • *****
  • Posts: 15495
  • Censorship about opinions does not belong here.
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.
« Last Edit: July 08, 2024, 08:17:01 am by Thaddy »
My great hero has found the key to the highway. Rest in peace John Mayall.
Playing: "Broken Wings" in your honour. As well as taking out some mouth organs.

alpine

  • Hero Member
  • *****
  • Posts: 1239
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.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

wp

  • Hero Member
  • *****
  • Posts: 12274
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

  • Hero Member
  • *****
  • Posts: 1239
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...
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.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

 

TinyPortal © 2005-2018