Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically show/hide properties in the IDE Object Inspector?

I came across an interesting feature while using Delhpi 10 Seattle. In Firedac, specifically a TFDConnection component, the Params property has some voodoo magic which can dynamically show and hide the properties in the IDE on the fly, depending on the value of another particular property. (I have no idea how long this has been available since I just started with Firedac). When you change the DriverID property in TFDConnection.Params, the rest of the properties in the Params show up in the IDE Object Inspector to be able to specify driver-specific properties.

Now I've investigated how this works, and it's a bunch of interface definitions, rooting from IFDStanDefinition. I cannot figure out how it's actually performing this in the IDE, other than that there's a TStringList involved utilizing the Name/Value pair functionality.

I would love to implement the same thing in my own component, in particular a TCollectionItem has a property ActionType which is an Enum type. I would like to dynamically show/hide properties depending on what value is selected for that one property.

How can I accomplish the same ability of showing/hiding properties in the IDE Object Inspector in my own component's collection item?

On a side note, I'm afraid part of the answer is that it expects all string values, judging by how you interact with this Params property via code.

like image 939
Jerry Dodge Avatar asked Oct 30 '22 22:10

Jerry Dodge


1 Answers

Write a property editor and include paVolatileSubProperties attribute when GetAttributes returns. The rest is about releasing old sub-property instance, and replacing with the new one (but they can be of any TPersistent class descendant, so it's not tied to the string list class).

like image 184
Victoria Avatar answered Nov 15 '22 05:11

Victoria