Re: focus problem



ixo one11 net (punky brewster did also) writes:

Howdy - i'm pretty new to the Gtk; module (as of last night), so
this might be a known thing (i've been unable to turn up any
info, tho) .. i've got an app that i've written both from scratch
and using glade, and there seems to be some invisible widget
(that i don't instantiate) that is allowing the keyboard focus ..

The Mandrake installer is using perl-gtk quite extensively, so
the main coder, Pixel (that's not me), tried to fix/workaround
this problem.

We don't have a clean solution.

Though... we have a dirty one :).

We handle it by adding the following to perl-gtk:

--- Gtk-Perl-0.7002.old/Gtk/xs/GtkContainer.xs  Wed Nov 10 12:35:24 1999
+++ Gtk-Perl-0.7002/Gtk/xs/GtkContainer.xs      Sat Mar 11 21:45:14 2000
@@ -106,6 +106,13 @@
        Gtk::Container  self
        Gtk::DirectionType      direction
 
+void
+ensure_focus(self, direction)
+       Gtk::Container  self
+       Gtk::DirectionType      direction
+       CODE:
+       if (GTK_WINDOW(self)->focus_widget == NULL)
+           gtk_container_focus(self, direction);
 
 #ifdef GTK_HAVE_CONTAINER_FOCUS_ADJUSTMENTS


And the following at each window creation (the window is $w):

    my $focusing;
    $w->signal_connect(focus => sub { 
        return 1 if $focusing;
        $focusing = 1;
        Gtk->idle_add(sub { $w->ensure_focus($_[0]); $focusing = 0; 0 }, $_[1]);
    }) if $w->can('ensure_focus');


Yes, this is dirty :-(. Complain to Pixel :).

-- 
Guillaume Cottenceau - http://people.mandrakesoft.com/~gc/



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