Re: [gtk-list] focus



On Thu, 8 Apr 1999, Patrick wrote:

> is there any way i can keep focus from leaving a
> widget? i have an entry widget that needs to keep
> focus when i press up/down arrow (i'm using those in a
> key press callback to implement a history feature)
> 
> i tried removing the GTK_CAN_FOCUS flag on the other
> widgets in the window, a menubar and notebook, but the
> entry still loses focus when i press up/down

that's the wrong aproach, you need to intercept the key event handling if
you handle up/down:


gtk_signal_connect (entry, "key_press_event", myf, NULL);
gint
myf (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
  gboolean handled = FALSE;
  switch (event->keyval)
  {
  case GDK_Up:
  case GDK_Down:
    /* do something */
    handled = TRUE;
  }
  
  if (handled)
    gtk_signal_emit_stop_by_name (widget, "key_press_event");
  
  return handled;
}

> 
> thanks in advance
> 
>  
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 

---
ciaoTJ



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