Re: [gtk-list] Disabling up & down cursors in an Entry.



Lee Benfield wrote:
> 
> Hi -
> 
> I'm trying to stop certain keys being handled in an Entry widget, (so
> when I hit up for example I don't change focus).  I've tried adding
> a signal handler to the widget for "key_press_event", which is called
> fine, but I can't stop the focus shifting.
> 
> I *guess* I should use gtk_signal_emit_stop (?) but have had no success.

  Here's what I do:

gint colorlist_key_press(GtkWidget* widget, GdkEventKey* event, gpointer
data)
{
  int x = -100;

  switch (event->keyval)
  {
    case GDK_Up: x = cur_color - 14; break;
    case GDK_Down: x = cur_color + 14; break;
    case GDK_Left: x = cur_color - 1; break;
    case GDK_Right: x = cur_color + 1; break;
  }

  if (x != -100)
    gtk_signal_emit_stop_by_name (GTK_OBJECT(widget),
"key_press_event");

  return TRUE;
}

Leonardo



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