Game Development Community

GuiMLTextCtrl Error in TGEA

by Austin Whitlatch · in Technical Issues · 06/20/2008 (10:22 am) · 3 replies

Alright, I'm having massive issues with the GuiMLTextCtrl. The control fails to update correctly in the engine. No error codes or anything are being thrown. What happens is this:

I have a button that updates the text. It then calls this function:

function setSpawn(%spawnid)
{   
   $toSpawn = %spawnid;
   switch(%spawnid)
   {
      case 1:
         txtFlavor1.text = "The marine is a native of california. His turn ons include: long walks on the beach, cuddling, and good old fashioned rape and pillaging.";
      case 2:
         txtFlavor1.text = "The rigger, while not the most manly of men, actually isn't man at all, but a women that used to think she was a man and her parents never decided to tell her the difference....";
      case 3:
         txtFlavor1.text = "Printers are not as harmless as they appear.";
   }
}

The code does not update unless I go into the GUI editor button (F10) and then it updates sometimes. It is pretty random on its update even then, but the text is changed when the different buttons are changed consistently. These buttons have been used to update a guiTxtCtrl and it worked fine.

Anyone have any idea how to make this update?

#1
06/20/2008 (11:11 am)
You have to use setText instead of assigning to the text property directly (consider it read-only). If you simply assign, the control will not marked as dirty.

txtFlavor1.setText( "The marine is a native ..." );
#2
06/20/2008 (11:21 am)
Checked the text property and it turns out it's not for the text contained in the control at all. In fact, text only refers to the *initial* text of the control. Once initialized, the property isn't used anymore and will never represent the actual text in the control. Use getText and setText.
#3
06/23/2008 (10:28 am)
Thanks Rene! That worked great.