[Solved]How to position the mouse?


#1

For example: I want to get and set the mouse’s position in a component rather than get its position by mouseDown(), mouseUp() etc… Can’t find a method to do this, am I missing something?

Thanks in advance.


#2

Ah, how stupid I am!

The methods are just in Desktop class. More wonderful is they are static methods :slight_smile:


#3

Just an FYI: the Desktop::setMousePosition method is there for backwards compatibility, but it was written back in the days before multi-touch and a more modern approach is to use the MouseInputSource classes for this.


#4

Thanks! I modified the implementation to:

Desktop::getInstance().getMainMouseSource().setScreenPosition (...);

Is this OK, Jules?


#5

Sure, that’d work fine.