OnSetBounds does not arrange the members correct
Description:
Sometimes if a class get opened in the composer or in the Prototyper, the object does not appear as expected. The arrangement of the members is implemented in the overwritten method OnSetBounds() and works fine if the Bounds get changed with the mouse in the composer.
Solution:
The reason for this behavior is usually the z-order. Since the z-order determines the sequence of the initialization from the bottom to the top. The Bounds property is usually in a lower order than the visual objects (Rectangle, Text, etc.) and therefore the Bounds are initialized before the visual objects. This means that the OnSetBounds() is called to arranges the members and afterwards the members get initialized with their default values which might not be the expected result from the OnSetBounds().
There are two possible solutions for this problem:
1. Change the order of the Bounds property to be topmost. Then the OnSetBounds() will be called after the initialization of the visual members.
2. Change the OnSetBounds() implementation to send a postsignal to a slot method. The postsignal will be processed before the next screen update, but – important for us - after the initialization was finished. If the arrangement of the visual members is done in a slot method, triggered by a postsignal, the described problems will not occur. Don’t forget the super(value) call.
See also:
Keywords:
Bounds, arrangement, order
Last update on 2010-08-19 by Mario Stefanutti.