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

1

5

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

Petronius answered 15/11, 2016 at 14:51 Comment(0)
M
9

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.

Melantha answered 15/11, 2016 at 15:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.