Re: [gtk-list] Re: Need advice on key_press_event.



On 1 Sep 1999, Owen Taylor wrote:

> 
> Preben Randhol <randhol@pvv.org> writes:
> 
> > Hi
> > 
> > We have made a canvaswidget (not the Gnome canvaswidget) that can be
> > scrolled up and down. What I know want to do is to add keybindings for
> > Pg_Down and Pg_Up (and some other keys as well). 
> > 
> > I can do this with an eventbox attached to the canvaswidget, but that
> > requires that the widget has focus. I would very much like to be able
> > to press Pg_Down no matter which widget has focus (perhaps except
> > entry/combobox widgets though) and get the canvas to scroll.
> > 
> > How would you go about to do this? Is there a mechanisme for doing
> > this. As the menu has shortcuts that work without the menubar having
> > focus, I thought there might be one.
> 
> Well, there are a couple of ways of doing it. You can use
> the accelerator mechanism. This basically does a binding
> of 
> 
>  key press on top level window => signal emission
> 
> You presumably already have an accelerator group if you
> have a menu where key bindings work, so you'd just
> need to call gtk_accel_group_add().

owen, you should really know better. most of the gtk_accel_group_*
API is internal stuff, and gtk_accel_group_add() is no exception to
this. what he really wants to use is gtk_widget_add_accelerator().

> The other way to do this is just to connect to 
> "key_press_event" on your toplevel window. All key presses
> get redirected to the toplevel window before being
> sent to the focus widget.
> 
> Regards,
>                                         Owen
> 

---
ciaoTJ



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