Re: [gtk-list] changing entry shortcut hooks



>  static GtkTextFunction control_keys[26] =
>  {
>    (GtkTextFunction)gtk_move_beginning_of_line,    /* a */
>    (GtkTextFunction)gtk_move_backward_character,   /* b */
>    ...
>  }
[snip]
>  I would like to change such entries. Is it planned to provide some
>  accessors functions to these arrays ?

It may be a good idea to provide some kind of gtk_entry_set_bindings()
function.  In the meantime, you can override the actions of keystrokes
in the way the file selector does it for the Tab key.  Let's say you
need to override the F1 key in the entry so that it does something,
and you need the keystroke not to be passed on to the entry:

static gint
my_key_handler (GtkWidget *entry, GdkEventKey *event, gpointer data)
{
	if (event->keyval == GDK_F1) {
		printf ("F1 was pressed in the entry\n");

		gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "key_press_event");
		return TRUE;
	}

	return FALSE;
}

{
	GtkWidget *entry;

	...

	gtk_signal_connect (GTK_OBJECT (entry), "key_press_event",
			    (GtkSignalFunc) my_key_handler, NULL);

	...
}

Good luck,

  Quartic



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