gamecreator Posted June 22, 2017 Share Posted June 22, 2017 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. Quote Link to comment Share on other sites More sharing options...
Josh Posted June 22, 2017 Share Posted June 22, 2017 That should not work like that. I was experimenting with SetText / AddText Quote 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 More sharing options...
Josh Posted October 14, 2017 Share Posted October 14, 2017 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. Quote 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 More sharing options...
GorzenDev Posted October 14, 2017 Share Posted October 14, 2017 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. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted October 14, 2017 Author Share Posted October 14, 2017 What do you guys mean by a script? I'm not using Lua so I don't even know where that would go or what that would look like. I could try adding Redraw. That sounds like it could help. And yes, I was intentionally working with textarea as I wanted to try adding lines too. Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted October 14, 2017 Share Posted October 14, 2017 a widget's functionality is always dictated by a lua script even if you dont use lua the widget does. for example a Widget::Button() always uses the script "Scripts/GUI/Button.lua" unless you link it to a custom script. so to say it plainly a widget always uses a lua script. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted October 14, 2017 Author Share Posted October 14, 2017 Fair enough. I guess the GUI system is a little too complex for me for the time being, especially with no C examples in the docs to work off of. I'll stick to doing my own but thank you for the info. Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted October 14, 2017 Share Posted October 14, 2017 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. 1 Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted October 14, 2017 Share Posted October 14, 2017 I hope you find it usefull Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.