Hello, i have a problem with LineEdit.
At start, i want to create a set of classes to simply handle ui controls.
Here is the list of classes I’m going to implement (all inherit directly from UIElement):
- CheckboxControl
- StringControl (1x LineEdit)
- NumberControl (1x LineEdit, 2x Button up / down)
- FileControl (1x LineEdit, 1x Button, 1x FileSelector)
- Vector3Control (3x NumberControl)
- ResourceRefControl
For all these classes, only one event: E_CONTROL_VALUE_CHANGED
That’s the idea, what do you think of this design?
For my part I do not see any problem but I prefer to have your opinion in passing.
Now, let’s come to my problem.
The LineEdit element does not center the text correctly when this element is created in the constructor of another element (element not yet attached).
StringControl constructor:
StringControl::StringControl(Context* context) : UIElement(context)
{
lineEdit_ = CreateChild<LineEdit>("LineEdit");
lineEdit_->SetInternal(true);
}
DefaultStyle.xml :
<element type="StringControl" auto="true">
<attribute name="Layout Mode" value="Horizontal" />
<element type="LineEdit" internal="true">
<attribute name="Min Size" value="50 24" />
<attribute name="Vert Alignment" value="Center" />
</element>
</element>
StringControl* control = uiGroup->CreateChild<StringControl>("RF_StringControl");
control->SetStyleAuto();
control->SetText("DefaultValueTextEdit");
Everything works pretty well apart from the text LineEdit that is hidden by default, you have to take the mouse to move the cursor position and finally see the text.
Is there a solution to solve this problem?
Apart from inheriting the StringControl class from LineEdit because this solution is not possible for FileControl for example.
NOTE : The origin of problem comes from this line not work :
<attribute name="Layout Mode" value="Horizontal" />
So i understand why EditLine haven’t width but why the SetLayoutMode is ignored ?