Re: [gtk-osx-users] command-h to hide app?



On Mon, 14 Oct 2013, John Ralls wrote:

On Oct 14, 2013, at 10:51 AM, Allin Cottrell <cottrell wfu edu> wrote:

Using gtkosxapplication, I get a "Hide <app>" item under my app's top-of-screen Mac menu, and this works fine if moused. However, it shows an accelerator of command-h and that doesn't work. [...]

Hide and Hide Others are Apple functions, not Gtk ones, so the accelerators only work if use-quartz-accelerators is enabled. It isn't by default because it messes up the responder chain for key bindings by grabbing the accelerator event before it's passed to Gtk. I suppose the fix is to add corresponding GtkActions that call [theApp hide:] and [theApp hideOtherApplications:] to catch the accelerators.

Thanks, John. I added a function to gtkosxapplication_quartz.c as follows:

/**
 * gtkosx_application_hide:
 * @self: The GtkosxApplication object
 *
 * Tell OS X to hide the application.
 */
void
gtkosx_application_hide (GtkosxApplication *self)
{
  [NSApp hide: self];
}

and it seems to work fine, when hooked up to command-h in my GTK app.
(I tried just doing [NSApp hide] first but that produced a crash).

Might this be worth adding to the library?

Allin Cottrell



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