Re: Tab behavior in GtkClutter



On Sat, Dec 8, 2012 at 1:28 AM, Canek PelÃez ValdÃs <caneko gmail com> wrote:
Hi; I'm using gtk-clutter in the (AFAIU) normal way:

GtkWindow -> GtkClutterEmbed -> ClutterStage (comes with
GtkClutterEmbed) -> GtkClutterActor -> GtkWidget

I use the stage to animate the widgets; that part seems to be working
correctly. However, in the innermost widget and its children the tab
behavior doesn't seem to work as in a normal Gtk+ application. In my
Clutter-Gtk application, if one of the widgets inside the
GtkClutterActor has the focus and I press Tab, then it loses the focus
and no other widget gets it. In a normal Gtk+ application, the next
focusable widget grabs the focus. I attach a little Vala example
showing the problem (Vala 0.18, Gtk+ 3.6.2, Clutter 1.12.2,
Clutter-Gtk 1.4.0).

Does anyone know how do I fix this so my Clutter-Gtk application has
the same tab behavior as a normal Gtk+ application?

Thanks in advance.

// Compile with valac --pkg gtk+-3.0 --pkg clutter-gtk-1.0 tab-example.vala
using Gtk;

public class TabExample {

        private Window window;

        public TabExample() {
                window = new Window();
                window.title = "Tab Example";
                window.delete_event.connect(() => {
                                Gtk.main_quit();
                                return true;
                        });

                var embed = new GtkClutter.Embed();
                embed.expand = true;
                window.add(embed);

                var stage = embed.get_stage();

                var grid = new Grid();
                grid.expand = true;
                var label = new Label("Input 1:");
                grid.attach(label, 0, 0, 1, 1);
                var entry = new Entry();
                entry.width_chars = 40;
                grid.attach(entry, 1, 0, 1, 1);
                label = new Label("Input 2:");
                grid.attach(label, 0, 1, 1, 1);
                entry = new Entry();
                entry.width_chars = 40;
                grid.attach(entry, 1, 1, 1, 1);
                grid.column_spacing = 6;
                grid.row_spacing = 6;
                grid.margin_left = 6;
                grid.margin_right = 6;
                grid.margin_top = 6;
                grid.margin_bottom = 6;
                grid.show_all();
                var actor = new GtkClutter.Actor.with_contents(grid);
                stage.add_child(actor);
        }

        public void show() {
                window.set_default_size(600, 100);
                window.show_all();
        }

        public static int main(string[] args) {
                if (GtkClutter.init(ref args) != Clutter.InitError.SUCCESS) {
                        GLib.warning("Could not initialize GtkClutter");
                        return 1;
                }

                var te = new TabExample();
                te.show();

                Gtk.main();

                return 0;
        }
}

I'm answering myself, since I got no response. The solution (it seems)
is to extend GtkClutter.Embed and override all keyboard handling, so
the extended class looks to Gtk+ like a dumb container. The idea was
first implemented (AFAICS) in gnome-boxes:

http://git.gnome.org/browse/gnome-boxes/tree/src/clutter-widget.vala

With this, all key handling works like in a regular Gtk+ application,
which is exactly what I needed.

Regards.
-- 
Canek PelÃez ValdÃs
Posgrado en Ciencia e IngenierÃa de la ComputaciÃn
Universidad Nacional AutÃnoma de MÃxico



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