Forward Mac OS menu shortcut events to the right menu.
2007-06-17 Richard Hult <richard@imendio.com> * gdk/quartz/gdkevents-quartz.c (gdk_event_translate): Forward Mac OS menu shortcut events to the right menu. svn path=/trunk/; revision=18178
This commit is contained in:
committed by
Richard Hult
parent
c15becd959
commit
decff53495
@ -1,3 +1,8 @@
|
|||||||
|
2007-06-17 Richard Hult <richard@imendio.com>
|
||||||
|
|
||||||
|
* gdk/quartz/gdkevents-quartz.c (gdk_event_translate): Forward
|
||||||
|
Mac OS menu shortcut events to the right menu.
|
||||||
|
|
||||||
2007-06-17 Richard Hult <richard@imendio.com>
|
2007-06-17 Richard Hult <richard@imendio.com>
|
||||||
|
|
||||||
* gdk/quartz/gdkevents-quartz.c (gdk_event_translate)
|
* gdk/quartz/gdkevents-quartz.c (gdk_event_translate)
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
|
|
||||||
#include "gdkscreen.h"
|
#include "gdkscreen.h"
|
||||||
@ -68,6 +69,18 @@ static void get_converted_window_coordinates (GdkWindow *in_window,
|
|||||||
gint *out_y);
|
gint *out_y);
|
||||||
static void append_event (GdkEvent *event);
|
static void append_event (GdkEvent *event);
|
||||||
|
|
||||||
|
/* A category that exposes the protected carbon event for an NSEvent. */
|
||||||
|
@interface NSEvent (GdkQuartzNSEvent)
|
||||||
|
- (void *)gdk_quartz_event_ref;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSEvent (GdkQuartzNSEvent)
|
||||||
|
- (void *)gdk_quartz_event_ref
|
||||||
|
{
|
||||||
|
return _eventRef;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
void
|
void
|
||||||
_gdk_events_init (void)
|
_gdk_events_init (void)
|
||||||
{
|
{
|
||||||
@ -1517,6 +1530,44 @@ gdk_event_translate (NSEvent *nsevent)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Special-case menu shortcut events. We create command events for
|
||||||
|
* those and forward to the corresponding menu.
|
||||||
|
*/
|
||||||
|
if ([nsevent type] == NSKeyDown)
|
||||||
|
{
|
||||||
|
EventRef event_ref;
|
||||||
|
MenuRef menu_ref;
|
||||||
|
MenuItemIndex index;
|
||||||
|
|
||||||
|
event_ref = [nsevent gdk_quartz_event_ref];
|
||||||
|
if (IsMenuKeyEvent (NULL, event_ref,
|
||||||
|
kMenuEventQueryOnly,
|
||||||
|
&menu_ref, &index))
|
||||||
|
{
|
||||||
|
MenuCommand menu_command;
|
||||||
|
HICommand hi_command;
|
||||||
|
|
||||||
|
if (GetMenuItemCommandID (menu_ref, index, &menu_command) != noErr)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
hi_command.commandID = menu_command;
|
||||||
|
hi_command.menu.menuRef = menu_ref;
|
||||||
|
hi_command.menu.menuItemIndex = index;
|
||||||
|
|
||||||
|
CreateEvent (NULL, kEventClassCommand, kEventCommandProcess,
|
||||||
|
0, kEventAttributeUserEvent, &event_ref);
|
||||||
|
SetEventParameter (event_ref, kEventParamDirectObject,
|
||||||
|
typeHICommand,
|
||||||
|
sizeof (HICommand), &hi_command);
|
||||||
|
|
||||||
|
SendEventToEventTarget (event_ref, GetMenuEventTarget (menu_ref));
|
||||||
|
|
||||||
|
ReleaseEvent (event_ref);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nswindow = [nsevent window];
|
nswindow = [nsevent window];
|
||||||
|
|
||||||
/* Ignore events for no window or ones not created by GDK. */
|
/* Ignore events for no window or ones not created by GDK. */
|
||||||
|
|||||||
Reference in New Issue
Block a user