Jump to content

[SOLVED] WidgetEditText not rendering text


photo

Recommended Posts

When WidgetEditText is put inside a vbox and the WidgetEditText's text crosses the vbox's bottom boundary, the rendering of the text stops.

 

Below is the complete code to reproduce the issue.

 


Gui gui;
WidgetVBox vbox;
WidgetButton button;
WidgetEditText text;

int init()
{
  gui = engine.getGui();

  vbox = new WidgetVBox(gui);
  vbox.setBackground(1);
  vbox.setWidth( 300 );
  vbox.setHeight( 200 );
  gui.addChild(vbox,GUI_ALIGN_OVERLAP | GUI_ALIGN_CENTER);

  text = new WidgetEditText(gui, "WidgetEditText..." );
  text.setPosition( 150, 0 );
  vbox.addChild(text, GUI_ALIGN_OVERLAP | GUI_ALIGN_FIXED );

  button = new WidgetButton(gui, "Drag Me" );
  button.setCallback( GUI_PRESSED, "OnPressed" );
  button.setCallback( GUI_RELEASED, "OnReleased" );
  vbox.addChild(button, GUI_ALIGN_OVERLAP | GUI_ALIGN_FIXED);

  return 1;
}

void OnPressed()
{
  text.setPosition( text.getPositionX() + gui.getMouseDX(), text.getPositionY() + gui.getMouseDY() );
}

int nCount = 0;
void OnReleased()
{
  text.addLine( format( "%d", nCount ) );
  nCount++;
}

int update()
{
  return 1;
}

int shutdown()
{
  return 1;
}

Link to comment

Hi Mohamed,

 

WidgetEditText has vertical string limit due performance issues (less draw calls). Try to add WidgetEditText as a second root to gui.

 

Here is modified init function:

 

int init()
{
  gui = engine.getGui();

  vbox = new WidgetVBox(gui);
  vbox.setBackground(1);
  vbox.setWidth( 300 );
  vbox.setHeight( 200 );
  gui.addChild(vbox,GUI_ALIGN_OVERLAP | GUI_ALIGN_FIXED | GUI_ALIGN_CENTER);

  text = new WidgetEditText(gui, "WidgetEditText..." );
  text.setPosition( 150, 0 );
  gui.addChild(text,GUI_ALIGN_OVERLAP | GUI_ALIGN_FIXED | GUI_ALIGN_CENTER);

  button = new WidgetButton(gui, "Drag Me" );
  button.setCallback( GUI_PRESSED, "OnPressed" );
  button.setCallback( GUI_RELEASED, "OnReleased" );
  vbox.addChild(button, GUI_ALIGN_OVERLAP | GUI_ALIGN_FIXED);

  return 1;
}

 

Does it solves your problem?

Link to comment

Thanks unclebob,

 

Even with this approach the issue appears once the text crosses the app window's bottom boundary.

 

If the WidgetEditText is put inside a WidgetScrollBox the text is rendered properly.

Link to comment

Hello Mogamed,

 

Sorry for late reply. Text limits for WidgetScrollBox is set by parent widget (we're using WidgetVBox as root container for GUI), so you can't change that. By the way, there are two solutions here:

 

1. You can use add WidgetScrollBox and hide it.

2. You can use WidgetLabel with rich text formatting enabled in it

Link to comment
×
×
  • Create New...