Spec-Zone .ru
спецификации, руководства, описания, API
|
public class ScrollEvent extends InputEvent
The event provides two different types of scrolling values: pixel-based and
character/line-based. The basic deltaX
and deltaY
values
give reasonable results when used as number of pixels
to scroll. For scrolling text (or other line-based content as tables) the
textDelta
values should be used if they are available. The
textDeltaXUnits
and textDeltaYUnits
determine how to
interpret the textDeltaX
and textDeltaY
values. If the
units are set to NONE
, the text-based values are not available
(not provided by the underlying platform) and the pixel-based values
need to be used.
For example, scrolling a graphical node can be achieved by following code:
node.setOnScroll(new EventHandler
A scroll event handler on text-based component behaving
according to system settings on all platforms should contain following logic:
switch(event.getTextDeltaYUnits()) {
case LINES:
// scroll about event.getTextDeltaY() lines
break;
case PAGES:
// scroll about event.getTextDeltaY() pages
break;
case NONE:
// scroll about event.getDeltaY() pixels
break;
}
Modifier and Type | Class and Description |
---|---|
static class |
ScrollEvent.HorizontalTextScrollUnits
Horizontal text-based scrolling units.
|
static class |
ScrollEvent.VerticalTextScrollUnits
Vertical text-based scrolling units.
|
Modifier and Type | Field and Description |
---|---|
static EventType<ScrollEvent> |
ANY
Common supertype for all scroll event types.
|
static EventType<ScrollEvent> |
SCROLL
This event occurs when user performs a scrolling action such as
rotating mouse wheel.
|
consumed, eventType, NULL_SOURCE_TARGET, target
Modifier and Type | Method and Description |
---|---|
Event |
copyFor(java.lang.Object newSource,
EventTarget newTarget)
Creates and returns a copy of this event with the specified event source
and target.
|
double |
getDeltaX()
Gets the horizontal scroll amount.
|
double |
getDeltaY()
Gets the vertical scroll amount.
|
double |
getSceneX()
Gets the horizontal position of the event relative to the
origin of the
Scene that contains the ScrollEvent's source. |
double |
getSceneY()
Gets the vertical position of the event relative to the
origin of the
Scene that contains the ScrollEvent's source. |
double |
getScreenX()
Gets the absolute horizontal position of the event.
|
double |
getScreenY()
Gets the absolute vertical position of the event.
|
double |
getTextDeltaX()
Gets the horizontal text-based scroll amount.
|
ScrollEvent.HorizontalTextScrollUnits |
getTextDeltaXUnits()
Gets the horizontal scrolling units for text-based scrolling.
|
double |
getTextDeltaY()
Gets the vertical text-based scroll amount.
|
ScrollEvent.VerticalTextScrollUnits |
getTextDeltaYUnits()
Gets the vertical scrolling units for text-based scrolling.
|
double |
getX()
Gets the horizontal position of the event relative to the
origin of the ScrollEvent's source.
|
double |
getY()
Gets the vertical position of the event relative to the
origin of the ScrollEvent's source.
|
boolean |
isAltDown()
Indicates whether or not the Alt modifier is down on this event.
|
boolean |
isControlDown()
Indicates whether or not the Control modifier is down on this event.
|
boolean |
isMetaDown()
Indicates whether or not the Meta modifier is down on this event.
|
boolean |
isShiftDown()
Indicates whether or not the Shift modifier is down on this event.
|
boolean |
isShortcutDown()
Indicates whether or not the host platform common shortcut modifier is
down on this event.
|
java.lang.String |
toString()
Returns a string representation of this
ScrollEvent object. |
clone, consume, fireEvent, getEventType, getTarget, isConsumed
public static final EventType<ScrollEvent> SCROLL
public static final EventType<ScrollEvent> ANY
public Event copyFor(java.lang.Object newSource, EventTarget newTarget)
Event
null
, it is
replaced by the NULL_SOURCE_TARGET
value.public double getDeltaX()
textDeltaX
and textDeltaXUnits
values should be
considered first.
The sign of the value is reversed compared to the coordinate system
(when you scroll right, the content actually needs to go left). So the
returned value can be simply added to the content's X
coordinate.
public double getDeltaY()
textDeltaY
and textDeltaYUnits
values should be
considered first.
The sign of the value is reversed compared to the coordinate system
(when you scroll down, the content actually needs to go up). So the
returned value can be simply added to the content's Y
coordinate.
public ScrollEvent.HorizontalTextScrollUnits getTextDeltaXUnits()
getTextDeltaX()
value. If the returned value is NONE
, the text-based
scrolling value is not available and the pixel-based
getDeltaX()
value needs to be used.public ScrollEvent.VerticalTextScrollUnits getTextDeltaYUnits()
getTextDeltaY()
value. If the returned value is NONE
, the text-based
scrolling value is not available and the pixel-based
getDeltaY()
value needs to be used.public double getTextDeltaX()
getTextDeltaXUnits()
value.getTextDeltaXUnits()
returns NONE
public double getTextDeltaY()
getTextDeltaYUnits()
value.getTextDeltaYUnits()
returns NONE
public final double getX()
public final double getY()
public final double getScreenX()
public final double getScreenY()
public final double getSceneX()
Scene
that contains the ScrollEvent's source.
If the node is not in a Scene
, then the value is relative to
the boundsInParent of the root-most parent of the ScrollEvent's node.Scene
that contains the ScrollEvent's sourcepublic final double getSceneY()
Scene
that contains the ScrollEvent's source.
If the node is not in a Scene
, then the value is relative to
the boundsInParent of the root-most parent of the ScrollEvent's node.Scene
that contains the ScrollEvent's sourcepublic final boolean isShiftDown()
public final boolean isControlDown()
public final boolean isAltDown()
public final boolean isMetaDown()
public final boolean isShortcutDown()
control
on Windows and meta
(command key) on Mac.true
if the shortcut modifier is down, false
otherwisepublic java.lang.String toString()
ScrollEvent
object.toString
in class java.util.EventObject
ScrollEvent
object.Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to