Skip to content

Commit

Permalink
Merge pull request #124 from ImJimmi/fix-mouse-interactions-again
Browse files Browse the repository at this point in the history
Fix mouse interactions on buttons with nested components
  • Loading branch information
ImJimmi authored Nov 28, 2023
2 parents b936734 + 7940b10 commit 37ebd0a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
5 changes: 5 additions & 0 deletions jive_components/accessibility/jive_IgnoredComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace jive
{
IgnoredComponent::IgnoredComponent()
{
setInterceptsMouseClicks(false, true);
}

std::unique_ptr<juce::AccessibilityHandler> IgnoredComponent::createAccessibilityHandler()
{
return createIgnoredAccessibilityHandler(*this);
Expand Down
2 changes: 2 additions & 0 deletions jive_components/accessibility/jive_IgnoredComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace jive
{
class IgnoredComponent : public juce::Component
{
public:
IgnoredComponent();
std::unique_ptr<juce::AccessibilityHandler> createAccessibilityHandler() override;
};
} // namespace jive
1 change: 0 additions & 1 deletion jive_layouts/layout/gui-items/content/jive_Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ namespace jive
idealHeight = juce::String{ calculateRequiredHeight() };

component->addComponentListener(this);
component->setInterceptsMouseClicks(false, false);
}
} // namespace jive

Expand Down
11 changes: 0 additions & 11 deletions jive_layouts/layout/gui-items/widgets/jive_Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ namespace jive
triggerClick(getButton());
};
getButton().addListener(this);
getButton().addComponentListener(this);
}

Button::~Button()
{
getButton().removeComponentListener(this);
getButton().removeListener(this);
}

Expand All @@ -109,15 +107,6 @@ namespace jive
toggled = getButton().getToggleState();
onClick.triggerWithoutSelfCallback();
}

void Button::componentChildrenChanged(juce::Component& comp)
{
auto& button = getButton();
jassertquiet(&comp == &button);

for (auto* child : button.getChildren())
child->addMouseListener(&button, true);
}
} // namespace jive

namespace juce
Expand Down
2 changes: 0 additions & 2 deletions jive_layouts/layout/gui-items/widgets/jive_Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace jive
class Button
: public GuiItemDecorator
, private juce::Button::Listener
, private juce::ComponentListener
{
public:
enum class TriggerEvent
Expand All @@ -22,7 +21,6 @@ namespace jive

private:
void buttonClicked(juce::Button* button) final;
void componentChildrenChanged(juce::Component& component) final;

void updateTriggerEvent();

Expand Down

0 comments on commit 37ebd0a

Please sign in to comment.