1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsMenuBarListener_h__
6 #define nsMenuBarListener_h__
8 #include "mozilla/Attributes.h"
9 #include "mozilla/EventForwards.h"
10 #include "nsIDOMEventListener.h"
12 // X.h defines KeyPress
20 /** editor Implementation of the DragListener interface
22 class nsMenuBarListener MOZ_FINAL
: public nsIDOMEventListener
25 /** default constructor
27 explicit nsMenuBarListener(nsMenuBarFrame
* aMenuBar
);
29 static void InitializeStatics();
31 NS_IMETHOD
HandleEvent(nsIDOMEvent
* aEvent
) MOZ_OVERRIDE
;
33 nsresult
KeyUp(nsIDOMEvent
* aMouseEvent
);
34 nsresult
KeyDown(nsIDOMEvent
* aMouseEvent
);
35 nsresult
KeyPress(nsIDOMEvent
* aMouseEvent
);
36 nsresult
Blur(nsIDOMEvent
* aEvent
);
37 nsresult
MouseDown(nsIDOMEvent
* aMouseEvent
);
39 static nsresult
GetMenuAccessKey(int32_t* aAccessKey
);
43 static bool IsAccessKeyPressed(nsIDOMKeyEvent
* event
);
46 /** default destructor
48 virtual ~nsMenuBarListener();
50 static void InitAccessKey();
52 static mozilla::Modifiers
GetModifiersForAccessKey(nsIDOMKeyEvent
* event
);
54 // This should only be called by the nsMenuBarListener during event dispatch,
55 // thus ensuring that this doesn't get destroyed during the process.
56 void ToggleMenuActiveState();
58 nsMenuBarFrame
* mMenuBarFrame
; // The menu bar object.
59 // Whether or not the ALT key is currently down.
61 // Whether or not the ALT key down is canceled by other action.
62 bool mAccessKeyDownCanceled
;
63 static bool mAccessKeyFocuses
; // Does the access key by itself focus the menubar?
64 static int32_t mAccessKey
; // See nsIDOMKeyEvent.h for sample values
65 static mozilla::Modifiers mAccessKeyMask
;// Modifier mask for the access key