Browse Source

OSX modal behaviour fix.

tags/2021-05-28
jules 13 years ago
parent
commit
7d953a629d
3 changed files with 13 additions and 21 deletions
  1. +4
    -5
      modules/juce_gui_basics/native/juce_mac_FileChooser.mm
  2. +2
    -3
      modules/juce_gui_basics/native/juce_mac_MainMenu.mm
  3. +7
    -13
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm

+ 4
- 5
modules/juce_gui_basics/native/juce_mac_FileChooser.mm View File

@@ -136,15 +136,14 @@ private:
// The OS view already plays an alert when clicking outside
// the modal comp, so this override avoids adding extra
// inappropriate noises when the cancel button is pressed.
// This override is also important because it stops the base class
// calling ModalComponentManager::bringToFront, which can get
// recursive when file dialogs are involved
class SilentDummyModalComp : public Component
{
public:
SilentDummyModalComp() {}
void inputAttemptWhenModal()
{
ModalComponentManager::getInstance()->bringModalComponentsToFront();
}
void inputAttemptWhenModal() {}
};
SilentDummyModalComp dummyModalComponent;


+ 2
- 3
modules/juce_gui_basics/native/juce_mac_MainMenu.mm View File

@@ -246,9 +246,8 @@ public:
{
const KeyPress& kp = keyPresses.getReference(0);
if ((kp.getKeyCode() != KeyPress::backspaceKey // (adding these is annoying because it flashes the menu bar
&& kp.getKeyCode() != KeyPress::deleteKey) // every time you press the key while editing text)
|| kp.getModifiers().isAnyModifierKeyDown())
if (kp != KeyPress::backspaceKey // (adding these is annoying because it flashes the menu bar
&& kp != KeyPress::deleteKey) // every time you press the key while editing text)
{
juce_wchar key = kp.getTextCharacter();
if (key == 0)


+ 7
- 13
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -792,9 +792,6 @@ public:
bool canBecomeKeyWindow()
{
if (sendModalInputAttemptIfBlocked())
return false;
return (getStyleFlags() & juce::ComponentPeer::windowIgnoresKeyPresses) == 0;
}
@@ -1668,16 +1665,17 @@ private:
static BOOL canBecomeKeyWindow (id self, SEL)
{
NSViewComponentPeer* const owner = getOwner (self);
return owner != nullptr && owner->canBecomeKeyWindow();
return owner != nullptr
&& owner->canBecomeKeyWindow()
&& ! owner->sendModalInputAttemptIfBlocked();
}
static void becomeKeyWindow (id self, SEL)
{
sendSuperclassMessage (self, @selector (becomeKeyWindow));
NSViewComponentPeer* const owner = getOwner (self);
if (owner != nullptr)
if (NSViewComponentPeer* const owner = getOwner (self))
owner->becomeKeyWindow();
}
@@ -1689,9 +1687,7 @@ private:
static NSRect constrainFrameRect (id self, SEL, NSRect frameRect, NSScreen*)
{
NSViewComponentPeer* const owner = getOwner (self);
if (owner != nullptr)
if (NSViewComponentPeer* const owner = getOwner (self))
frameRect = owner->constrainRect (frameRect);
return frameRect;
@@ -1718,9 +1714,7 @@ private:
static void zoom (id self, SEL, id sender)
{
NSViewComponentPeer* const owner = getOwner (self);
if (owner != nullptr)
if (NSViewComponentPeer* const owner = getOwner (self))
{
owner->isZooming = true;
objc_super s = { self, [NSWindow class] };


Loading…
Cancel
Save