Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 17, 2001 21:02:52

Jared B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gtk_widget_add_accelerator


Hi,
Ive having trouble adding accelerator to the enter key. I want the
enter key to map to a button click event.

If I use....

gtk_widget_add_accelerator(find_window, "find_signal", accel_group,
GDK_Escape, 0, GTK_ACCEL_VISIBLE);
gtk_signal_connect(GTK_OBJECT (find_window), "find_signal",
GTK_SIGNAL_FUNC (on_find_button_clicked), NULL);
....

The code works fine. When I press Esc my sig handler gets called.

But, If I change the key to 'GDK_Return', the handler does not get
called. I think it may be becuase the current focus is in an entry field.

Im new at this so Im sure there may be an easy workaround... or maybe a
better way to add the accelerator. Any suggestions?


Thanks.

J.

_______________________________________________
gtk-list mailing list
http://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#2 Aug. 17, 2004 11:46:39

Pramod P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gtk_widget_add_accelerator


Hi All,

I am having trouble with adding acclerators.
I want the "Shift Ctrl Minus" key to map to some
event.

Here's what I am doing:

gchar * label = ...;
GtkWidget *menuItemWidget =
gtk_menu_item_new_with_mnemonic(label);
...
GdkAccelGroup *accel = ... ;
AccelKey = 45; //for "-" key
accelMod = GDK_CONTROL_MASK | GDK_SHIFT_MASK;

gtk_widget_add_accelerator(menuItemWidget, "activate",
accel, AccelKey, (GdkModifierType)accelMod,
GTK_ACCEL_VISIBLE);
g_signal_connect(G_OBJECT(menuItemWidget),
"activate",
G_CALLBACK (ActivateCallback), (gpointer)somedata);

I also added an accelerator so that "Shit Ctrl +" key
is mapped to another event.

These two keys (ShiftCtrlPlus and ShiftCtrlMinus) are
part of menus and I can see the shortcuts as part of
the menu names but the "Shift Ctrl Minus" does not
work instead "Ctrl Minus" emits the signal. No such
problem exists for "Shift Ctrl Plus" key.

Any idea what might be going wrong?

Thanks




__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.http://promotions.yahoo.com/new_mail_______________________________________________
gtk-list mailing list
http://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#3 Sept. 8, 2004 14:49:45

Pramod P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

gtk_widget_add_accelerator


Hi All,

I am trying to add an accelerator. Here's a sample
code:

GtkWidget *w=gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *e=gtk_button_new_from_stock(GTK_STOCK_OK);
GtkAccelGroup *gag = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(w),gag);
g_signal_connect(G_OBJECT(e),"clicked",G_CALLBACK(print),NULL);
guint mod = GDK_SHIFT_MASK;
mod |= GDK_CONTROL_MASK;
gtk_widget_add_accelerator(e,"clicked",gag,'6',GDK_CONTROL_MASK|GDK_SHIFT_MASK,GTK_ACCEL_VISIBLE);
gtk_container_add(GTK_CONTAINER(w),e);
gtk_widget_show(e);
gtk_widget_show(w);


When the application is run, Ctrl+6 calls the callback
but not Ctrl+Shift+6. Any idea what's going on here?
(I am using GTK 2.0.9)

Thanks
-Pramod






__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!http://promotions.yahoo.com/new_mail_______________________________________________
gtk-list mailing list
http://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#4 July 21, 2017 03:38:50

AaronNem
Registered: 2017-07-18
Posts: 2
Reputation: +  0  -
Profile   Send e-mail  

gtk_widget_add_accelerator

This post is being moderated

Offline

#5 July 23, 2017 13:20:35

AaronNem
Registered: 2017-07-18
Posts: 2
Reputation: +  0  -
Profile   Send e-mail  

gtk_widget_add_accelerator

This post is being moderated

Offline

Board footer

Moderator control

Enjoy the 24th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support