Re: [gtk-list] Accelerators and labels



On Tue, 8 Jun 1999, Perry Harrington wrote:

> I have been doing some GTK hacking lately. I will admit to being a
> relative newbie, but I have exhausted Altavista and gtk.org on these
> matters.
> 
> Anyhow, here goes:
> 
> I want to have an accelerator attached to a button, so when the accelerator
> key is pressed (Control S, for example) the button's "clicked" method will
> activate.
> 
> Here is the snippet I've got:
> 
> 	accelerators = gtk_accel_group_new();
> 
>         gtk_accel_group_attach(accelerators, GTK_OBJECT(window));

gtk_accel_group_attach() is an internal function, use
 gtk_window_add_accel_group() instead.
 
> 	...
> 
>  	gtk_widget_add_accelerator (button_send,
>                                   "clicked",
>                                   accelerators,
>                                   0x13,
>                                   0,
>                                   GTK_ACCEL_VISIBLE);
> 
> Is this possible?  Am I on the right track?

what kind of keysym should 0x13 be? Gdk provides symbolic names for
all meaningfull key settings, you better make use of those ;)
e.g. control S would be (..., GDK_S, GDK_CONTROL_MASK, ..)
also, you might want to use GTK_ACCEL_LOCKED instead of GTK_ACCEL_VISIBLE,
since you don't have a widget to display the accelerator (GtkAccelLabel
inside the button could do this for instance) and you probably don't
want users to use this specific accelerator within menus (since they
have no possibility to change the accelerator on the button).

> 
> --Perry
> 

---
ciaoTJ



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