Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why some properties are hidden from Object Inspector when more than one item is selected?

I've noticed that some properties disappear from the Object Inspector when selecting more than one item.

Why does this happen and how to control this behavior when creating a component?

Example:

Add 2 buttons (TButton) to a form and select one of them.

enter image description here

In the Object Inspector you can see all TButton's published properties (Note that there's also the Constraints property).

enter image description here

Add the other button to the current selection (Click while pressing Shift key).

enter image description here

As you can see, some properties have been hidden from Object Inspector (Note that the Constraints is no more visible).

enter image description here

like image 725
Fabrizio Avatar asked Nov 15 '16 14:11

Fabrizio


1 Answers

Whether a property is displayed when multiple objects are selected is controlled by the property editor configured for that property. Property editors (descended from TPropertyEditor in DesignEditors.pas) have a GetAttributes method that returns a set of attributes that apply to the editor. If the set includes paMultiSelect, then the property will be displayed.

Given that the property value is displayed as the constraint values, rather than just (TSizeConstraints), I conclude that that property is not using the generic TClassProperty editor. That editor sets paMultiSelect, but based on your pictures, the property editor to TSizeConstraints doesn't. It was probably an oversight.

You could try registering your own property editor. Find the property editor currently registered for TSizeConstraints (by searching the source code for TSizeConstraints, for instance) and, in a design-time package, declare a new class descended from that one. Override GetAttributes to return the value you need. Finally, follow examples elsewhere in the code to call RegisterPropertyEditor.

like image 132
Rob Kennedy Avatar answered Oct 14 '22 02:10

Rob Kennedy