1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-18 00:54:19 +00:00

OSX modal behaviour fix.

This commit is contained in:
jules 2012-09-07 18:52:30 +01:00
parent 6d4252e571
commit 7d953a629d
3 changed files with 13 additions and 21 deletions

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;

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)

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] };