Re: bug in the key binding system ?



Erwann Chenede <erwann.chenede@excite.com> writes:

> 	Hello,
> 
> 	I think there is a bug in the key bindings and 	
> 	GtkEditable signals.
> 	I've got the following in my gtkrc :
> 
> 	binding "test"
> 	{
> 	  bind "F3" {
> 	  "debug-msg" ("Test Msg")
> 	  }
> 	}
> 
> 	class "GtkEditable" binding : highest "test"
> 	class "GtkEntry" binding : highest "test"
> 
> 	when I'm pressing F3 in a GtkEntry widget not happen.
> 	I've investigated a bit : when I press F3 
> 	gtk_bindings_activate is called but not cannot find any
> 	binding.
> 	I think the binding activation is occurring on the wrong 	
> 	widget, here GtkWindow (see stack trace attached).

GtkEntry doesn't using GtkBindings right now, so it never
calls gtk_bindings_activate() (this will be fixed in GTK+-2.0)

A workaround hack you can do if it is your own app is:

======
static gboolean
editable_key_press_cb (GtkWidget *widget, GdkEventKey *event)
{
  if (gtk_bindings_activate (GTK_OBJECT (widget), event->keyval, event->state))
    {
      gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
      return TRUE;
    }
  else
    return FALSE;
}

[...]

  gtk_signal_connect (GTK_OBJECT (editable), "key_press_event",
		      GTK_SIGNAL_FUNC (editable_key_press_cb), NULL);
======

Regards,
                                        Owen




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