| @@ -178,6 +178,12 @@ public: | |||||
| owner = nullptr; | owner = nullptr; | ||||
| } | } | ||||
| bool escapeKeyPressed() override | |||||
| { | |||||
| closeButtonPressed(); | |||||
| return true; | |||||
| } | |||||
| private: | private: | ||||
| String windowPosProperty; | String windowPosProperty; | ||||
| ScopedPointer<Component>& owner; | ScopedPointer<Component>& owner; | ||||
| @@ -33,14 +33,22 @@ DialogWindow::~DialogWindow() | |||||
| { | { | ||||
| } | } | ||||
| bool DialogWindow::keyPressed (const KeyPress& key) | |||||
| bool DialogWindow::escapeKeyPressed() | |||||
| { | { | ||||
| if (escapeKeyTriggersCloseButton && key == KeyPress::escapeKey) | |||||
| if (escapeKeyTriggersCloseButton) | |||||
| { | { | ||||
| setVisible (false); | setVisible (false); | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | |||||
| } | |||||
| bool DialogWindow::keyPressed (const KeyPress& key) | |||||
| { | |||||
| if (key == KeyPress::escapeKey && escapeKeyPressed()) | |||||
| return true; | |||||
| return DocumentWindow::keyPressed (key); | return DocumentWindow::keyPressed (key); | ||||
| } | } | ||||
| @@ -239,6 +239,12 @@ public: | |||||
| #endif | #endif | ||||
| /** Called when the escape key is pressed. | |||||
| This can be overridden to do things other than the default behaviour, which is to hide | |||||
| the window. Return true if the key has been used, or false if it was ignored. | |||||
| */ | |||||
| virtual bool escapeKeyPressed(); | |||||
| protected: | protected: | ||||
| //============================================================================== | //============================================================================== | ||||
| /** @internal */ | /** @internal */ | ||||