Re: [gtk-list] Label parse_uline in gtk--



On 3 May 1999, Anders Melchiorsen wrote:

> Gtk_Label::parse_uline returns void in gtk-- but it seems to return
> guint in GTK+. How come?
> 
> I am having a really hard time figuring out how to correctly use the
> accelerator (short cut) stuff as easily as possible. It is not
> mentioned in the tutorial and the reference manual is empty. Is there
> somewhere that I can dig up this information, or will I just have to
> experiment?
> 
> Ideally I would like to just put an underscore in a label and then
> have it all happen automatically, but it seems like this is not really 
> possible?

hm underlined accelerators in non-menu labels are somewhat uncommon,
for normal accelerators, GtkAccelLabel is provided, but if you intend
to use underlined accelerators, there is no way around doing stuffs
yourself (like creating and eventually updating the label value).
the gtk_item_factory_create_item() function in gtkitemfactory.c shows
how to setup a label and a widget with underlined acceleratos.

first, you need to figure the accelerator:

  guint accel_key = gtk_label_parse_uline (GTK_LABEL (label), name);

and then setup the accelerator for the widget you want to see
activated, given that you have an accelerator group attached
to your main window:

    gtk_widget_add_accelerator (widget,
                                "activate",
                                accel_group,
                                accel_key, 0,
                                GTK_ACCEL_LOCKED);

(you can pass in GDK_MOD1_MASK instead of the `0' in the above call,
 if you want your accelerator to act on ALT+key presses).


> -- 
> Mvh. Anders
> 

---
ciaoTJ



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