Browse Source

Fix for a problem with accelerator keys running modal comps while an OSX menu is open.

tags/2021-05-28
jules 12 years ago
parent
commit
4c44d852b3
3 changed files with 25 additions and 10 deletions
  1. +10
    -0
      modules/juce_core/native/juce_osx_ObjCHelpers.h
  2. +10
    -5
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm
  3. +5
    -5
      modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm

+ 10
- 0
modules/juce_core/native/juce_osx_ObjCHelpers.h View File

@@ -54,6 +54,16 @@ namespace
}
}
//==============================================================================
template <typename ObjectType>
struct NSObjectRetainer
{
inline NSObjectRetainer (ObjectType* o) : object (o) { [object retain]; }
inline ~NSObjectRetainer() { [object release]; }
ObjectType* object;
};
//==============================================================================
template <typename SuperclassType>
struct ObjCClass


+ 10
- 5
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -676,11 +676,9 @@ public:
return used;
}
else
{
if (handleKeyUpOrDown (false))
return true;
}
if (handleKeyUpOrDown (false))
return true;
}
return false;
@@ -688,6 +686,10 @@ public:
bool redirectKeyDown (NSEvent* ev)
{
// (need to retain this in case a modal loop runs in handleKeyEvent and
// our event object gets lost)
const NSObjectRetainer<NSEvent> r (ev);
updateKeysDown (ev, true);
bool used = handleKeyEvent (ev, true);
@@ -715,6 +717,9 @@ public:
void redirectModKeyChange (NSEvent* ev)
{
// (need to retain this in case a modal loop runs and our event object gets lost)
const NSObjectRetainer<NSEvent> r (ev);
keysCurrentlyDown.clear();
handleKeyUpOrDown (true);


+ 5
- 5
modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm View File

@@ -26,13 +26,13 @@
class UIViewComponent::Pimpl : public ComponentMovementWatcher
{
public:
Pimpl (UIView* const view_, Component& owner_)
: ComponentMovementWatcher (&owner_),
view (view_),
owner (owner_),
Pimpl (UIView* const v, Component& comp)
: ComponentMovementWatcher (&comp),
view (v),
owner (comp),
currentPeer (nullptr)
{
[view_ retain];
[view retain];
if (owner.isShowing())
componentPeerChanged();


Loading…
Cancel
Save