how get a widget and use it ?

  • 2 Replies
  • 81 Views
*

che2a

  • *
  • 12
    • View Profile
how get a widget and use it ?
« 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

*

texus

  • *****
  • 1555
    • View Profile
    • Texus's Blog
Re: how get a widget and use it ?
« Reply #1 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();
« Last Edit: 26 May 2020, 18:11:02 by texus »

*

che2a

  • *
  • 12
    • View Profile
Re: how get a widget and use it ?
« Reply #2 on: 26 May 2020, 18:29:38 »
Thank you it works !

And thank you for your work tgui is awesome :)