Re: how do I find out if the focused object is an Gtk::Entry?



Le 03/05/2011 09:58, Ming-ching Chiu a écrit :
> Hi, In my program I need to determine if the focused widget is an
> entry so that I can set its text. I use get_focus() to get the
> focused object, but I don't know how to determine if it is an entry.
> Is there any way to tell if the returned widget is an entry?
> thanks!

I would have used a C++ dynamic cast like in the example below :


Gtk::Entry * entry;

entry = dynamic_cast< Gtk::Entry * >( myWindow->get_focus() );
if( entry )
{
  // set the text
}


> Best, Ming-ching

Best regards.
Guillaume


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]