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

I noticed that some properties disappear from the Object Inspector when more than one item is selected.

Why is this happening and how to control this behavior when creating a component?

Example:

Add two buttons ( TButton ) to the form and select one of them.

enter image description here

In the Object Inspector, you can see all the published properties of TButton (note that there is also a Constraints property).

enter image description here

Add another button to the current selection (press when you press the Shift key ).

enter image description here

As you can see, some properties were hidden from the Object Inspector (note that Constraints no longer displayed).

enter image description here

+5
source share
1 answer

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

Given that the property value is displayed as constraint values, and not just (TSizeConstraints), I conclude that this property does not use the common TClassProperty editor. This editor sets paMultiSelect , but based on your images, the property editor before TSizeConstraints does not work. It was probably oversight.

You can try registering your own property editor. Find the property editor that is currently registered for TSizeConstraints (for example, by searching for the source code for TSizeConstraints), and declare a new class from this package in the development time package. Override GetAttributes to return the desired value. Finally, follow the examples elsewhere in the code to call RegisterPropertyEditor .

+8
source

Source: https://habr.com/ru/post/1259771/


All Articles