Children validator evaluation order

I have a dialog with many children. To validate one of these children, I
need the value of another children. In short, both are TextCtrl where the
user must enter floats and the value in the second TextCtrl must be larger
than that of the first one.

I have a generic validator for float values in TextCrtl that can accept a
callable for the minimum or the maximum acceptable values, so it is easy for
me to use the value of the first TextCrtl as the minimum value for the
second one and it works fine. However, for this to work, the first TextCtrl
must be validated before the second one, otherwise it might not be possible
to correctly interpret is as a float.

I have tested the behavior on a few platforms, and it seems that the
children are validated in the order they were created. However, I cannot
find documentation that guarantees this behavior. Does anyone here know if
this behavior is guaranteed? Do you know of any platform where this is not
the case?

(I know I could create a validator for the dialog instead, but I believe it
would make my code less elegant).

Thank you for your help!

Stéphane

St�phane Larouche wrote:

I have a dialog with many children. To validate one of these children, I
need the value of another children. In short, both are TextCtrl where the
user must enter floats and the value in the second TextCtrl must be larger
than that of the first one.

I have a generic validator for float values in TextCrtl that can accept a
callable for the minimum or the maximum acceptable values, so it is easy for
me to use the value of the first TextCrtl as the minimum value for the
second one and it works fine. However, for this to work, the first TextCtrl
must be validated before the second one, otherwise it might not be possible
to correctly interpret is as a float.

I have tested the behavior on a few platforms, and it seems that the
children are validated in the order they were created. However, I cannot
find documentation that guarantees this behavior. Does anyone here know if
this behavior is guaranteed? Do you know of any platform where this is not
the case?

Not guaranteed since it's not documented, but not likely to change either IMO. The window's children list is traversed in order when calling the validators (with a recursive descent if the child has children and the flag is set) and I don't see why anybody would ever want to change that.

BTW if the tab order is modified then the changes will be reflected in the order of the items in the children list, so it would be more accurate to say that the order of processing the validators follows the tab order, not the necessarily the creation order.

···

--
Robin Dunn
Software Craftsman