[Solved]How to position the mouse?

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.

Ah, how stupid I am!

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

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.

1 Like

Thanks! I modified the implementation to:

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

Is this OK, Jules?

Sure, that’d work fine.

1 Like