Reputation: 11986
I'm trying to add an accelerator to a "Play" GTK+ 3.0 menu item using the following C code:
gtk_widget_add_accelerator(play, "activate", accel_group, GDK_KEY_F5, NULL, GTK_ACCEL_VISIBLE);
I want the "Play" menu item to be activated when the user presses the F5 key. However, when I try to compile I get the following error:
/usr/include/gtk-3.0/gtk/gtkwidget.h:504:9: note: expected 'GdkModifierType' but argument is of type 'void *'
I don't want to add a modifier, just have the menu item activate when the user presses the F5 key. I realized that I can pass a 0
as the argument (since GdkModifierType
is just a binary mask), but is there a preferred way over this solution -- perhaps a preprocessor macro called GDK_NONE_MASK
or something to that effect?
Upvotes: 2
Views: 614
Reputation: 15634
That's right, you're not supposed to pass pointers (e.g. NULL
) to an enum
parameter. Attempting to do so is wrong, and this is what the compiler told you.
You can get away with 0
. Implicit conversion from ints to enums will kick in.
To be more explicit, you can write (GdkModifierType)0
as the argument.
Upvotes: 1