Re: how do I find out if the focused object is an Gtk::Entry?
- From: Yann Leydier <yann leydier info>
- To: gtkmm-list gnome org
- Subject: Re: how do I find out if the focused object is an Gtk::Entry?
- Date: Tue, 03 May 2011 10:53:14 +0200
You can use a dynamic_cast.
Pointer style:
Gtk::Entry *ent(dynamic_cast<Gtk::Entry*>(widget_ptr));
if (ent)
{
…
}
Reference style (I'm not 100% sure):
try
{
Gtk::Entry &ent(dynamic_cast<Gtk::Entry&>(widget_ref));
…
}
catch (std::bad_cast &)
{ }
Another way could be to user Gtk's functions to retrieve the inner GType…
yann
On 05/03/11 09:58, Ming-ching Chiu wrote:
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!
Best,
Ming-ching
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]