Is there are any implementation of rectangle selection in javafx?


Question

I mean like in file managers, when you would click, drag the mouse, creating a rectangle selection and after the mouse released selection is created?

I could do that like this (pseude-code like):

onMousePressed:
setGestureStarted(true)

onMouseMoved:
if isGestureStarted:
   changeRectangle(event.getX, event.getY)

onMouseReleased:
   select(getSelectionRectange())

But I thought that it's pretty common behavior and maybe it's already in framework.

EDIT1:

I was trying to do zoomable linechart. And I actually came across library to do that. It's pretty good, but could be better though. Right now I'm considering the actual worth of javaFX in our web project, because I don't like how such thing as zoomable chart is not in the library. Probably would be better with javascript (except I should learn it first, but It shouldn't be that hard).

1
2
3/31/2014 7:54:59 PM


You would probably need to make your own implementation for this. I found your pseudo code is quiet good. If you like to select for any component then you need to first create a simple rectangular boundary which is easily possible by your pseudo code.

Now for finding out either your node is inside that boundary then you need to do iteration of all the nodes/children of certain Parent Object by using this function: Node Intersect check

I would suggest to use that function after the onMouseReleased or if you like to see things in realtime then it is preferable in onMouseMoved

3
3/31/2014 6:44:18 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon