Re: focus behavior



I've found the answer to my question so I'll share it with the list just
in case someone ever run into the same problem.

I had a bug in my size_allocate method. I did something like:

  if (GTK_WIDGET_REALIZED (widget))
    {
      widget->allocation = *allocation;
      gdk_window_move_resize (widget->window,
                              allocation->x, allocation->y,
                              allocation->width, allocation->height);
   }

while I should be doing this:

  widget->allocation = *allocation;
  if (GTK_WIDGET_REALIZED (widget))
    {
      gdk_window_move_resize (widget->window,
                              allocation->x, allocation->y,
                              allocation->width, allocation->height);
   }

Don't ask me why but this fixed the focus problem. Without this fix if I
put my widget in a window with several other widgets my widget gets the
focus as soon as the window is displayed.

Regards

Lorenzo

El mié, 28-04-2004 a las 15:26, Lorenzo Gil Sanchez escribió:
Hi,

I'm having problems with focus with my custom container. In my
init_class function I do:

  widget_class->focus = gtk_grid_focus;

To override the widget focus implementation.

Let's say I have a window with several widgets like, for example, this
layout:

+-------+
| entry |
+-------+
| entry |
+-------+
| grid  |
+-------+
| entry |
+-------+

where there is an VBox and three entries and a grid (my custom
container).

As soon as the window is shown my gtk_grid_focus is called and I guess
it should't be happening. I guess only when the focus is in the second
entry and the user press the tab (or down arrow) key that function
should be called. Is this correct?

Otherwise, If I do a gtk_widget_grab_focus() as soon as I get the
gtk_grid_focus called the initial focus is set to the Grid when the
window is shown and this is not what is expected.

Any clue?

Lorenzo


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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