From 3eff0639587e0d76467a900872bc7f4897d49120 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 14 Apr 2014 15:54:33 +0200 Subject: [PATCH] WebPositive: let escape close the menu. * Intercept the escape key to mean "stop loading" only when menus are closed. --- src/apps/webpositive/BrowserWindow.cpp | 11 ++++++++++- src/apps/webpositive/BrowserWindow.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index 79936918c6..4ce93f9344 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -334,6 +334,7 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings, B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS), fIsFullscreen(false), fInterfaceVisible(false), + fMenusRunning(false), fPulseRunner(NULL), fVisibleInterfaceElements(interfaceElements), fContext(context), @@ -707,7 +708,7 @@ BrowserWindow::DispatchMessage(BMessage* message, BHandler* target) _InvokeButtonVisibly(fFindCloseButton); return; } - } else if (bytes[0] == B_ESCAPE) { + } else if (bytes[0] == B_ESCAPE && !fMenusRunning) { if (modifierKeys == B_COMMAND_KEY) _ShowInterface(true); else { @@ -1125,6 +1126,14 @@ BrowserWindow::MenusBeginning() { _UpdateHistoryMenu(); _UpdateClipboardItems(); + fMenusRunning = true; +} + + +void +BrowserWindow::MenusEnded() +{ + fMenusRunning = false; } diff --git a/src/apps/webpositive/BrowserWindow.h b/src/apps/webpositive/BrowserWindow.h index 8b2093a74d..a2d228f5ff 100644 --- a/src/apps/webpositive/BrowserWindow.h +++ b/src/apps/webpositive/BrowserWindow.h @@ -103,6 +103,7 @@ public: virtual void MessageReceived(BMessage* message); virtual bool QuitRequested(); virtual void MenusBeginning(); + virtual void MenusEnded(); virtual void ScreenChanged(BRect screenSize, color_space format); @@ -246,6 +247,7 @@ private: bool fIsFullscreen; bool fInterfaceVisible; + bool fMenusRunning; BRect fNonFullscreenWindowFrame; BMessageRunner* fPulseRunner; uint32 fVisibleInterfaceElements;