Bug #183841. Shortcut for "Open Context Menu" doesn't work, shift-F10. Send context menu event when someone hits shift-F10. r=bryner,sr=blizzard patch from bolian.yin@sun.com.

This commit is contained in:
blizzard%redhat.com 2002-12-14 22:23:06 +00:00
Родитель 99bfd8b147
Коммит 1ce5f96100
1 изменённых файлов: 34 добавлений и 2 удалений

Просмотреть файл

@ -80,6 +80,10 @@ static GdkWindow *get_inner_gdk_window (GdkWindow *aWindow,
gint x, gint y,
gint *retx, gint *rety);
static PRBool is_context_menu_key (const nsKeyEvent& inKeyEvent);
static void key_event_to_context_menu_event(const nsKeyEvent* inKeyEvent,
nsMouseEvent* outCMEvent);
/* callbacks from widgets */
static gboolean expose_event_cb (GtkWidget *widget,
GdkEventExpose *event);
@ -1548,8 +1552,16 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
}
}
// send the key press event
DispatchEvent(&event, status);
// before we dispatch a key, check if it's the context menu key.
// If so, send a context menu key event instead.
if (is_context_menu_key(event)) {
nsMouseEvent contextMenuEvent;
key_event_to_context_menu_event(&event, &contextMenuEvent);
DispatchEvent(&contextMenuEvent, status);
}
else
// send the key press event
DispatchEvent(&event, status);
return TRUE;
}
@ -3361,6 +3373,26 @@ get_inner_gdk_window (GdkWindow *aWindow,
return aWindow;
}
inline PRBool
is_context_menu_key(const nsKeyEvent& aKeyEvent)
{
return (aKeyEvent.keyCode == NS_VK_F10 && aKeyEvent.isShift &&
!aKeyEvent.isControl && !aKeyEvent.isMeta && !aKeyEvent.isAlt);
}
void
key_event_to_context_menu_event(const nsKeyEvent* aKeyEvent,
nsMouseEvent* aCMEvent)
{
memcpy(aCMEvent, aKeyEvent, sizeof(nsInputEvent));
aCMEvent->eventStructType = NS_MOUSE_EVENT;
aCMEvent->message = NS_CONTEXTMENU_KEY;
aCMEvent->isShift = aCMEvent->isControl = PR_FALSE;
aCMEvent->isAlt = aCMEvent->isMeta = PR_FALSE;
aCMEvent->clickCount = 0;
aCMEvent->acceptActivation = PR_FALSE;
}
#ifdef ACCESSIBILITY
/**
* void