0

What I'd like to achieve is the following:

When the left mouse-button is pressed AND the mouse is moved (while the mouse button is still pressed!) I would like to invoke a certain method. Basically I'd like to be able to move around the canvas, just like in e.g. Blender, where you navigate when your mouse-button is pressed and you move the mouse.

Now I know how to check on a certain event, like so:

val pane = new StackPane
pane.onMouseClicked = (event: MouseEvent) => 
{
    // Mouse button was pressed
}

but how to do a inner-check now?

Something like this:

pane.onMouseClicked = (event: MouseEvent) => 
{
    pane.onMouseMoved = (event: MouseEvent) => ()
}

will obviously not work, because when the button is pressed the first time, another handler is registered and would now/from here on fire whenever I move the mouse, which is not what I want.

Of course I searched, but I could not find anything appropriate AND without nasty hacks.

pheeleeppoo
  • 1,491
  • 6
  • 25
  • 29
  • 3
    "When the left mouse-button is pressed AND the mouse is moved", is this not a [MouseDragged](https://docs.oracle.com/javase/8/javafx/api/javafx/scene/Node.html#setOnMouseDragged-javafx.event.EventHandler-) event? – jewelsea Feb 17 '16 at 22:16
  • @jewelsea:You're right. I'd still like to find a more general approach, but I'll have a look at MouseDragged to see how it was implemented there! –  Feb 18 '16 at 16:31

0 Answers0