[Gtk-sharp-list] accelgroup.Connect problem
lasagnadavide at gmail.com
Sun Apr 11 18:17:43 EDT 2010
Thanks for the quick answer. I understand the code you wrote, which
basically binds the shortcut to the menuitem to a handler.
However this won't work if the menubar is not visible. What i'd like to do
is to bind some shortcuts to the main window, without the menubar.
Is this possible?
On 11 April 2010 22:56, Matthew Pirocchi <matthew.pirocchi at gmail.com> wrote:
> Hi Davide,
> The "IntPtr" parameter refers to a C function pointer, not a C# method
> group. It's generally just used internally, for interop with Gtk+.
> Generally, setting up accelerators looks something like this:
> // Initialize the AccelGroup
> AccelGroup accelGroup = new AccelGroup ();
> AddAccelGroup (accelGroup);
> // Create the create the menu item you want to set up the accelerator for
> MenuItem menuItem = new MenuItem ();
> // Hook up the event handler to the Activated event
> menuItem.Activated += HandleMenuItemActivated;
> // Add the accelerator for the menu item
> ("activate", accelGroup,
> new AccelKey (Gdk.Key.Left,
> Gdk.ModifierType.MetaMask, AccelFlags.Visible));
> Hope this helps,
> - Matthew
> On Sun, Apr 11, 2010 at 2:57 PM, Davide Lasagna <lasagnadavide at gmail.com>wrote:
>> Hi all,
>> I'm new to mono although i've had some previous experience with pygtk. I
>> have a problem with an accelgroup. What i want to do is to bind Alt+left to
>> a calback.
>> Here is the code:
>> AccelGroup accelgroup = new AccelGroup();
>> accelgroup.Connect(Gdk.Key.Left, Gdk.ModifierType.MetaMask,
>> AccelFlags.Visible, HandleGobackClicked );
>> Compiling this gives:
>> ./MainWindow.cs(62,36): error CS1502: The best overloaded method match for
>> `Gtk.AccelGroup.Connect(uint, Gdk.ModifierType, Gtk.AccelFlags,
>> System.IntPtr)' has some invalid arguments
>> /usr/lib/cli/gtk-sharp-2.0/gtk-sharp.dll (Location of the symbol related
>> to previous error)
>> ./MainWindow.cs(62,36): error CS1503: Argument `#1' cannot convert
>> `Gdk.Key' expression to type `uint'
>> How can i solve it? The docs are not very complete on this, and i can't
>> find tutorials or examples.
>> Thanks for pointing me in the right direction.
>> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gtk-sharp-list