Problems with GtkEntry's grabbing focus

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

 



I'm writing a GTK+ application that uses an OpenGL capable drawing area widget (via the GtkGLExt extension). This drawing area responds to various mouse events. There are several other widgets for other various settings. I have been trying to also get the drawing area widget to respond to key press events and have been unable to do so. In the process of creating a stripped down version of the code that I was going to include with this post, the stripped version responded to key press events. After some more thinking I believe the problem with the original was that the drawing area widget was not getting the focus when the mouse point was inside it.

Thus, I tried adding Enter Notify and Leave Notify events to this window. When the mouse enters the drawing area, I use a gtk_window_get_focus to store which widget currently had the focus, and then make the drawing area grab the focus. I now am able to receive key press events in this widget. When the mouse leaves the drawing area, in the Leave Notify callback I call a gtk_widget_grab_focus with the widget I obtained from the get_focus durng the Enter Notify. The problem that I am having is that if the previously focused widget was something like a GtkEntry widget, then when it grabs the focus the entire contents is hightlighted and if a key is pressed, the contents is erased. Why is the entire contents hightlighted when it grabs the focus? It would be nice in such cases that the cursor returned back to where it was previously. Given a widget pointer, is there a way to tell what type of widget it is so that if it is an entry widget I can do something so that the text is unselected. I'm assuming that a similar problem may occur with a TextView widget but have not confirmed this.



_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux