it seems that this method returns true even if you don't click the mouse:
void MyComponent::mouseOver( const MouseEvent &event ) {
if( event.mouseWasClicked() ) {
std::cout << "mouseOver: CLICKED\n";
}
}
looks like the problem might be here:
bool MouseEvent::mouseWasClicked() const noexcept { return wasMovedSinceMouseDown == 0; }
here is line: 2562 in juce_Component, it looks like wasMovedSinceMouseDown is initialized with 'false'
const MouseEvent me (source, relativePos, source.getCurrentModifiers(), MouseInputSource::invalidPressure,
this, this, time, relativePos, time, 0, false);
mouseMove (me);
here's how wasMovedSinceMouseDown is initialized in the mouseEvent constructor:
wasMovedSinceMouseDown ((uint8) (mouseWasDragged ? 1 : 0))
mouseWasClicked() returns true, because wasMovedSinceMouseDown is initialized to uint8 '\0'
I'm not sure if this is a bug or not, but when i'm mousing over a window without clicking on the window, I am not expecting "mouseWasClicked()" to return true.
It seems like you should add a member to the mouseEvent class that specifically stores if the event was created out of a mouse-click, no?
Here is a possible fix:
bool MouseEvent::mouseWasClicked() const noexcept {
return (numberOfClicks != 0);
}
