replacing old style Component::enableUnboundedMouseMovement


I’m updating some old code that used enableUnboundedMouseMovement this way:

[code]void HeaderPanel::sliderDragStarted(Slider* slider)
if(slider == outLevelSlider)

// do other stuff…

slider->enableUnboundedMouseMovement(slider->getSliderStyle() != Slider::Rotary);


void HeaderPanel::sliderDragEnded(Slider* slider)

This stopped being compiled since the unbounded mouse movement handling has been moved into MouseInputSource. What’s the cleanest way to achieve the same effect as before with the new refactoring?


Probably Desktop::getInstance().getDraggingMouseSource (0)->enableUnboundedMouseMovement (true). (better check that it’s not a null pointer though).

You don’t really need to worry about disabling it, as that’ll happen when they let go anyway.


Some code needs to be changed regarding this subject:

Line 377 of juce_MouseInputSource.cpp

Desktop::setMousePosition (current->getScreenBounds() .getConstrainedPoint (current->getMouseXYRelative()));

is not conceptually correct, should be replaced with

Desktop::setMousePosition (current->relativePositionToGlobal (current->getLocalBounds() .getConstrainedPoint (current->getMouseXYRelative())));

Do you agree?


Ah yes, you’re right. I think what I probably meant to write was actually just:

Desktop::setMousePosition (current->getScreenBounds().getConstrainedPoint (lastScreenPos));