Stopping mouseEvents or using a snapshot?


I have a component which is filled with buttons, i have two usecases for this:

  1. i want to be able to klick all the buttons to change their color (this works)
  2. i want to be able to drag the component that holds the buttons across my screen, ive tried to use createComponentSnapshot() but when scaling down it looks bad, ive also tried to use SetIntercepsMouseClicks() but thats kinda doing the opposite of what i want (if i got that right)

how do i stop the component from passing the mouseEvent to its children?


To stop sending the events to the child components use
setInterceptsMouseClicks (true, false);
The first bool is the component itself, the second bool is forwarding to children.

Didn’t that work?

does this affect the child of the child as well or do i have to manually set the interceptsmouseklicks for all children further down?

ive cycled through all configs for setinterceptsmouseklicks and (false, false) does stop the buttons lighting up on mouseover and i cant klick them anymore, every other combination seems to behave the same

Like I wrote before, first bool the component itself, the second for it’s children.

Since the events are handed down from top level component, once the chain is interrupted no child nor grand child will get any mouse event.

Another note: despite it’s name “mouseClicks” it will interrupt ALL mouse events, like mouseEnter, mouseDrag, mouseDown etc…

Basically the first bool makes hitTest return always false and the second bool stops from iterating over the children (assuming false for all hitTest of the children).

yea, thats how i understood the function as well, i do have pointers in my juce::arrays where all the buttons and components with containers of those buttons are, does the setinerceptmouseklicks have a problem with that? is this not recommanded? because all actions do still end up on my buttons (mouse over as well as mouse down)