Reputation: 1581
Good day all,
I have a simple Dialog
started after click button, I post my code:
Dialog dialog;
super();
dialog = new Dialog("Dialog example");
dialog.addText(strFmt("Text to show"));
dialog.addText(strfmt("SecondText to show"));
dialog.run();
I will show a Dialog
window loollike this :
It's possible to set the position from code the Text: Text to show ? For example, if I want to centered position the second text how should I do?
I tried to put blanks in the code:
dialog.addText(strfmt(" Text to show"));
But nothing changes, and this I think not good method. I saw any suggestions on Web but or I do not use well or is not suitable for me: Example-suggestions. Exist a method to do what I want?
Thanks for help,
enjoy!
Upvotes: 1
Views: 4055
Reputation: 18051
You can center the text using the form control:
Dialog dialog = new Dialog("Dialog example");
DialogText t1 = dialog.addText(strFmt("Text to show"));
DialogText t2 = dialog.addText(strfmt("SecondText to show"));
FormStaticTextControl c1 = t1.control();
c1.widthMode(FormWidth::ColumnWidth);
c1.alignment(FormAlignment::Center);
dialog.run();
The first control is now centered (to the surrounding group).
You have to give it ColumnWidth
, otherwise the control would have the minimum size and the centering would have no effect.
Upvotes: 1