Browse Source

Added a callback method DialogWindow::escapeKeyPressed() and used it to fix a minor introjucer bug with tool windows

tags/2021-05-28
jules 9 years ago
parent
commit
76177fc431
3 changed files with 22 additions and 2 deletions
  1. +6
    -0
      extras/Introjucer/Source/Utility/jucer_MiscUtilities.h
  2. +10
    -2
      modules/juce_gui_basics/windows/juce_DialogWindow.cpp
  3. +6
    -0
      modules/juce_gui_basics/windows/juce_DialogWindow.h

+ 6
- 0
extras/Introjucer/Source/Utility/jucer_MiscUtilities.h View File

@@ -178,6 +178,12 @@ public:
owner = nullptr;
}
bool escapeKeyPressed() override
{
closeButtonPressed();
return true;
}
private:
String windowPosProperty;
ScopedPointer<Component>& owner;


+ 10
- 2
modules/juce_gui_basics/windows/juce_DialogWindow.cpp View File

@@ -33,14 +33,22 @@ DialogWindow::~DialogWindow()
{
}
bool DialogWindow::keyPressed (const KeyPress& key)
bool DialogWindow::escapeKeyPressed()
{
if (escapeKeyTriggersCloseButton && key == KeyPress::escapeKey)
if (escapeKeyTriggersCloseButton)
{
setVisible (false);
return true;
}
return false;
}
bool DialogWindow::keyPressed (const KeyPress& key)
{
if (key == KeyPress::escapeKey && escapeKeyPressed())
return true;
return DocumentWindow::keyPressed (key);
}


+ 6
- 0
modules/juce_gui_basics/windows/juce_DialogWindow.h View File

@@ -239,6 +239,12 @@ public:
#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:
//==============================================================================
/** @internal */


Loading…
Cancel
Save