TGUI Forum

General Category => Help requests => Topic started by: che2a on 26 May 2020, 13:37:35

Title: how get a widget and use it ?
Post by: che2a on 26 May 2020, 13:37:35
Hello, when i get a widget i have a widget::ptr

But i need to get the widget to use moveToFront() because he is displayed behind an another widget

I need to do something like that :
tgui::MenuBar::Ptr widget = gui->get<tgui::MenuBar>("MenuBar");
widget->moveTofront();
 

Thank you
Title: Re: how get a widget and use it ?
Post by: texus on 26 May 2020, 18:05:31
Code like that exists, you just need to make the "f" a capital letter (moveToFront instead of moveTofront).

If you don't need to call any function specific to MenuBar then you can skip the cast to MenuBar and have code that works for any type of widget:
tgui::Widget::Ptr widget = gui->get("MenuBar");
widget->moveToFront();
Title: Re: how get a widget and use it ?
Post by: che2a on 26 May 2020, 18:29:38
Thank you it works !

And thank you for your work tgui is awesome :)