From 288e17885a07678d7c9eab93abb3401c6c14c5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 3 Jun 2007 19:23:03 +0000 Subject: [PATCH] Implemented B_CLOSE_ON_ESCAPE as mentioned on the mailing list. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21308 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Window.h | 1 + src/kits/interface/Window.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h index e8ca9b16d7..66f1ba9fb8 100644 --- a/headers/os/interface/Window.h +++ b/headers/os/interface/Window.h @@ -82,6 +82,7 @@ enum { B_QUIT_ON_WINDOW_CLOSE = 0x00100000, B_SAME_POSITION_IN_ALL_WORKSPACES = 0x00200000, B_AUTO_UPDATE_SIZE_LIMITS = 0x00400000, + B_CLOSE_ON_ESCAPE = 0x00800000 }; #define B_CURRENT_WORKSPACE 0 diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index d247c05b1c..85586cdb0e 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -3138,6 +3138,15 @@ BWindow::_HandleKeyDown(BMessage* event) return true; } + // Optionally close window when the escape key is pressed + if (key == B_ESCAPE && (Flags() & B_CLOSE_ON_ESCAPE) != 0) { + BMessage message(B_QUIT_REQUESTED); + message.AddBool("shortcut", true); + + PostMessage(&message); + return true; + } + // Handle shortcuts if ((modifiers & B_COMMAND_KEY) != 0) { // Command+q has been pressed, so, we will quit