Jump to content

how can I cast Unigine::WidgetPtr to Unigine::WidgetEditLinePtr?


photo

Recommended Posts

I'm writing a plugin which can get current focused widget, if this focused widget is WidgetEditLine then plugin do something.

 

 

Unigine::GuiPtr gui = Unigine::Gui::get();
 
Unigine::WidgetPtr widget = gui->getFocus();
 
if(widget->getType() == 25) {
   // plugin api didn't export the enum for the widget type, so I use value 25  for WidgetEditLine type
   // then How can I get the correct Unigine::WidgetEditLinePtr?
   Unigine::WidgetEditLinePtr edit = ......
 
}

 

I've tried with dynamic_cast, it won't work, so How can I get the correct type?

Link to comment

Just call WidgetEditLine::create(widget) function to cast the WidgetPtr to the WidgetEditLinePtr type and check the resulted pointer via their .get() function.

Link to comment
×
×
  • Create New...