Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 17 ■ i3D Game Square SeleCtion: uSinG the piCkreSult ClaSS with 3D moDelS

The .getX() method call will return the double value for the horizontal position for the event relative
to the origin of the MouseEvent source. The .getY() method call will return the double value for the vertical
position for the event relative to the origin of the MouseEvent source. The .getZ() method call will return a
double value for the depth position for the event, relative to the origin of the MouseEvent source.
The .isAltDown() method call can be used to ascertain whether the Alt modifier key is being held down
during this event. It returns a true or false (boolean) value. The .isControlDown() method call can be used
to ascertain whether the Ctrl modifier key is being held down during this event. It also returns a true or false
(boolean) value. The .isMetaDown() method call can be used to ascertain whether the META modifier
key is being held down during this event. It also returns a true or false (boolean) value. The .isShiftDown()
method call can be used to ascertain whether the SHIFT modifier key is being held down during this event.
It also returns a true or false (boolean) value.
The .isDragDetect() method call should be used to determine whether this MouseEvent will be
followed by a DRAG_DETECTED event and will return a boolean true (yes drag detected) or false (no drag
not detected) data value.
An .isMiddleButtonDown() method call can be used to determine whether the middle mouse button
is being held down. It will return a true boolean value if your middle button (mouse button #2) is currently
depressed.
The .isPopupTrigger() method call should be used to determine whether this event is a pop-up menu
trigger event for the platform. It will return true if the mouse event is in fact the pop-up menu trigger event
for the platform.
The .isPrimaryButtonDown() method call will return the true boolean value if your primary
mouse button (button #1, which is usually the left mouse button) is currently being pressed. The
.isSecondaryButtonDown() method call will return the true boolean value if your secondary button
(button #2, which is usually the right mouse button) is currently being pressed.
The .isShortcutDown() method call will return whether the host platform’s common shortcut modifier
is being held down during this MouseEvent.
The .isStillSincePress() method call uses a boolean value to indicate whether the mouse cursor stayed
in the system-provided hysteresis area since the last mouse pressed event that occurred before this event.
The .isSynthesized() method call returns a boolean value that indicates whether the MouseEvent has
been synthesized by using a touchscreen device, instead of the usual mouse event source device, such as the
mouse, track ball, track pad, or similar mouse-emulation hardware device.
Finally, a void .setDragDetect(boolean dragDetect) method call is used to augment drag detection
behavior when using MouseEvent handling in conjunction with drag detection using a mouse, track pad, or
touchscreen device.


Implementing Spinner UI Functionality: Mouse Event Handling


Let’s create a createSceneProcessing() method to hold the Scene object creation, configuration, and event-
processing Java code. The Scene scene object must be created after the root Group Node object has been
created, so this method must be called after the createBoardGameNodes() method call, where these Node
objects are created. This is done using the following Java statement, also shown highlighted in light blue
(and wavy red underlining) in Figure 17-1:


createSceneProcessing();

Free download pdf