Jump to content

GUI Commands Meant To Be Cumulative?


gamecreator
 Share

Recommended Posts

I have the following code, which does something I didn't expect:

GUI *gui = Leadwerks::GUI::Create(context);
Widget *widget = Widget::TextArea(10, 10, 400, 300, gui->GetBase());
widget->SetText("Text field");
widget->SetText("Adds a second line");
widget->SetLayout(500, 50, 500, 500);

This ends up creating two text fields, with two lines each.  The second SetText adds a second line to the first, instead of replacing it (as I would expect).  The SetLayout creates an exact copy of the textarea at 500, 50.  If you do another SetText after SetLayout, only the second text area gets the additional text line.  Is this how this is supposed to work?  Since there are no C++ documentation examples, I kind of have to guess at what the Lua stuff does.  How do you replace text if SetText just keeps adding to it?  How do you move a widget without copying it (SetPosition is there, undocumented, but doesn't work)?

I still didn't figure out what a separate base is supposed to accomplish or if it's necessary.  And there's something about adding a script to it which goes over my head.

Link to comment
Share on other sites

  • 3 months later...

I don't think it created two text fields, I think the original one just didn't get cleared.  Try setting the base widget's script to a panel so there is something there.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

your code creates a textarea which is differant from a textfield.
a textarea is always multiline.
a textfield is just one line.

setlayout works as supposed to just dont forget widget->Redraw() after setting layout.

also like josh said the basewidget needs a panel script.
if you dont want a visible panel you can always use SetObject('backgroundcolor', new Vec4(0,0,0,0)); to make it transparant.

Link to comment
Share on other sites

i am currently creating a tutorial blog where i try to explain as much as i can of what i found out playing with this system.
to be honest it all sounds more complex than it actually is.

the widget system gives you almost unlimited freedom as to what a GUI element does and how it reacts.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...