MyGUI / mygui

Fast, flexible and simple GUI.
http://mygui.info/
Other
724 stars 207 forks source link

Problem with replace tags of comboboxes items #216

Closed mitra-projects closed 3 years ago

mitra-projects commented 3 years ago

I created a combobox of this type

`

                <Property key="Text_TextAlign" value="Center"/>
                <Property key="ComboBox_AddItem" value="#{example1}"/>
                <Property key="ComboBox_AddItem" value="#{example2}"/>
                <Property key="ComboBox_AddItem" value="#{example3}"/>
                <Property key="ComboBox_AddItem" value="#{example4}"/>
                <Property key="ComboBox_AddItem" value="#{example5}"/>
                <Property key="ComboBox_AddItem" value="#{example6}"/>
                <Property key="ComboBox_AddItem" value="#{example7}"/>
                <Property key="ComboBox_AddItem" value="#{example8}"/>
            </Widget>`

but it seems the tags replacement with the language file text doesn't work, at place of normal text in execution appears the tag text without the first 5 chars ("le1}", "le2}", "le3}", etc) . For all the other widgets the replacement works. My version is the 3.4.0 .

mitra-projects commented 3 years ago

the problem is the same reported by this user in 2011 https://www.ogre3d.org/addonforums/17/t-14270.html

mitra-projects commented 3 years ago

I solved changing all the setcaption instructions in MyGUI_Listbox.cpp and MyGUI_Combobox.cpp with setCaptionWithReplacing; Is there a reason because the original code doesn't use setCaptionWithReplacing?

Altren commented 3 years ago

Should be safe to do so, but at the time of load, not every time in runtime: MyGUIEngine/src/MyGUI_ComboBox.cpp line 463, add replaceTags there, like this

        else if (_key == "AddItem")
            addItem(LanguageManager::getInstance().replaceTags(_value));

And same for the MyGUIEngine/src/MyGUI_ListBox.cpp line 983

Please test this changes on the LayoutEditor, just run it and see if Widget properties on the right panel look good. If there are no issues I'll accept PR with changes you mentioned.

This is slightly incomplete solution, but I can't come up with something right now, so this changes are OK for now. Complete solution should affect all text properties, that come from layout file.

mitra-projects commented 3 years ago

thanks; just to be sure I understood; I have to use the replacetags in the additem at place of use setcaptionwithreplacing change, or I have to keep both the changes?

Altren commented 3 years ago

You need to change only two places I mentioned and keep other places intact.

mitra-projects commented 3 years ago

Done, it seems to work; i tested the layout editor with one of demo layout and it shows the tags correctly; i tested also the replacement in my application and it is done in the correct way.

image

Altren commented 3 years ago

Good, waiting for PR.

mitra-projects commented 3 years ago

PR created

Altren commented 3 years ago

Thank you. Merged.