michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef nsMenuBarListener_h__ michael@0: #define nsMenuBarListener_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsIDOMEventListener.h" michael@0: michael@0: // X.h defines KeyPress michael@0: #ifdef KeyPress michael@0: #undef KeyPress michael@0: #endif michael@0: michael@0: class nsMenuBarFrame; michael@0: class nsIDOMKeyEvent; michael@0: michael@0: /** editor Implementation of the DragListener interface michael@0: */ michael@0: class nsMenuBarListener : public nsIDOMEventListener michael@0: { michael@0: public: michael@0: /** default constructor michael@0: */ michael@0: nsMenuBarListener(nsMenuBarFrame* aMenuBar); michael@0: /** default destructor michael@0: */ michael@0: virtual ~nsMenuBarListener(); michael@0: michael@0: static void InitializeStatics(); michael@0: michael@0: NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE; michael@0: michael@0: nsresult KeyUp(nsIDOMEvent* aMouseEvent); michael@0: nsresult KeyDown(nsIDOMEvent* aMouseEvent); michael@0: nsresult KeyPress(nsIDOMEvent* aMouseEvent); michael@0: nsresult Blur(nsIDOMEvent* aEvent); michael@0: nsresult MouseDown(nsIDOMEvent* aMouseEvent); michael@0: michael@0: static nsresult GetMenuAccessKey(int32_t* aAccessKey); michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: static bool IsAccessKeyPressed(nsIDOMKeyEvent* event); michael@0: michael@0: protected: michael@0: static void InitAccessKey(); michael@0: michael@0: static uint32_t GetModifiers(nsIDOMKeyEvent* event); michael@0: michael@0: // This should only be called by the nsMenuBarListener during event dispatch, michael@0: // thus ensuring that this doesn't get destroyed during the process. michael@0: void ToggleMenuActiveState(); michael@0: michael@0: nsMenuBarFrame* mMenuBarFrame; // The menu bar object. michael@0: // Whether or not the ALT key is currently down. michael@0: bool mAccessKeyDown; michael@0: // Whether or not the ALT key down is canceled by other action. michael@0: bool mAccessKeyDownCanceled; michael@0: static bool mAccessKeyFocuses; // Does the access key by itself focus the menubar? michael@0: static int32_t mAccessKey; // See nsIDOMKeyEvent.h for sample values michael@0: static uint32_t mAccessKeyMask;// Modifier mask for the access key michael@0: }; michael@0: michael@0: michael@0: #endif