Class SceneDriver
- All Implemented Interfaces:
WindowInput
Two levels. The WindowInput methods are the raw calls a backend makes, one event each,
queued until inputBatchEnded() dispatches them, exactly as a frame's input arrives. The
gestures — click(Widget), press(int), type(java.lang.String), moveTo(float, float), scroll(float, float, float, float) — are a
whole user action each, batch included, and return the driver so they can be chained.
Scene scene = new Scene(form);
scene.layoutPass(400, 300);
drive(scene).click(nameField).type("Ada").press(Keys.ENTER);
The scene's input is not on Scene itself, because an application never calls it: a
window does. A driver is cheap, and drive(scene) may be called per event.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcharTyped(int codepoint) Committed text input, one code point (IME/layout-aware, after key events).click(float x, float y) A left click at a point: the pointer moves there, the button goes down and up, the batch ends.A left click at the centre of the widget with this id.A left click at the centre of a widget, where the last layout pass placed it.static SceneDrivervoidfilesDropped(List<Path> paths, float x, float y) Files dragged from the OS and dropped on the window, at a point of its content area in logical points: the widget under that point receives them.voidEnd of one native poll: dispatch the accumulated batch now.voidkeyEvent(int key, int layoutCodePoint, boolean pressed, boolean repeat, int modifiers) A key went down, repeated or came up.voidmouseButton(int button, boolean pressed, int modifiers, float x, float y, int clickCount) Button press/release at the given cursor position, with how many presses in a row this is, counted by the backend with the platform's own double-click interval and distance: 1 for a single press, 2 for the second of a double click.voidmouseDelta(float dx, float dy) Relative pointer motion while the window is inPointerMode.RELATIVE: unbounded deltas in logical points (raw/unaccelerated where the platform supports it), replacingWindowInput.mouseMoved(float, float)for the duration of the capture.voidmouseMoved(float x, float y) moveTo(float x, float y) Moves the pointer and ends the batch: a hover.voidpointerEntered(boolean entered) Cursor entered (true) or left the window's content area.voidpreeditChanged(String text, int caret, int targetStart, int targetLength) In-progress IME composition ("preedit") for the focused text input: the still-composing text, its caret, and the stretch of it the input method is converting now (the target the user is choosing a candidate for), shown inline but not yet committed (the commit arrives later viaWindowInput.charTyped(int)).press(int key) A key pressed and released with no modifier.press(int key, int modifiers) A key pressed and released with modifiers held.scene()scroll(float deltaX, float deltaY, float x, float y) A wheel or trackpad scroll over a point.voidscrolled(float deltaX, float deltaY, float x, float y) Wheel/trackpad scroll; deltas in native notches (positive = up/left).voidscrolled(float deltaX, float deltaY, float x, float y, boolean gestureBegins) A scroll the platform says begins a new gesture: the fingers came down on a trackpad or on a mouse whose surface scrolls, inertia from the gesture before still running or not.Text typed into whatever has the keyboard, one code point at a time, as the platform delivers committed characters.voidThe bound window was destroyed.voidwindowFocusChanged(boolean focused) The window gained or lost OS input focus.voidwindowFullscreenChanged(boolean fullscreen) The window entered (true) or left fullscreen:NativeWindow.isFullscreen()changed its answer.voidwindowResized(float logicalWidth, float logicalHeight) Window content resized (logical points).voidzoomed(float scale, float x, float y, boolean gestureBegins) A pinch on a trackpad: a request to zoom around the point by a factor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface limn.backend.spi.WindowInput
canEditFocused, dragLeft, dragOver, dropped, editFocused, keyEvent, mouseButton
-
Method Details
-
drive
- Parameters:
scene- the scene to drive- Returns:
- a driver delivering to that scene's window input
-
scene
- Returns:
- the scene this driver delivers to
-
click
A left click at a point: the pointer moves there, the button goes down and up, the batch ends.- Parameters:
x- logical x in the sceney- logical y in the scene- Returns:
- this driver
-
click
A left click at the centre of a widget, where the last layout pass placed it.- Parameters:
widget- a widget in this driver's scene, laid out- Returns:
- this driver
- Throws:
IllegalArgumentException- when the widget is not in this scene
-
click
A left click at the centre of the widget with this id.- Parameters:
id- the id, asScene.find(String)looks it up- Returns:
- this driver
- Throws:
IllegalArgumentException- when no widget in the scene has that id
-
moveTo
Moves the pointer and ends the batch: a hover.- Parameters:
x- logical x in the sceney- logical y in the scene- Returns:
- this driver
-
scroll
A wheel or trackpad scroll over a point.A scroll can be dropped as the tail of a gesture. A fresh key press that a widget acts on ends the wheel stream still arriving, which is what stops a trackpad's inertia from scrolling away what an arrow key just revealed. So a scroll that arrives within 150 ms of the previous one, on the scene's clock, after such a key press, is dropped, and with the wall clock a test's calls are microseconds apart. A test that scrolls, presses a key and scrolls again builds its scene with a clock it advances (
new Scene(root, clock)) and moves that clock past 150 ms before the second scroll.- Parameters:
deltaX- horizontal amount, in wheel notchesdeltaY- vertical amount, in wheel notches; positive scrolls up, as the platforms reportx- logical x of the pointery- logical y of the pointer- Returns:
- this driver
-
press
A key pressed and released with no modifier.- Parameters:
key- the key code, fromKeys- Returns:
- this driver
-
press
A key pressed and released with modifiers held.- Parameters:
key- the key code, fromKeysmodifiers- theKeys.MOD_*bits held- Returns:
- this driver
-
type
Text typed into whatever has the keyboard, one code point at a time, as the platform delivers committed characters. Keys that are not text (Enter, Tab, arrows) arepress(int).- Parameters:
text- the text- Returns:
- this driver
-
mouseMoved
public void mouseMoved(float x, float y) - Specified by:
mouseMovedin interfaceWindowInput
-
mouseDelta
public void mouseDelta(float dx, float dy) Description copied from interface:WindowInputRelative pointer motion while the window is inPointerMode.RELATIVE: unbounded deltas in logical points (raw/unaccelerated where the platform supports it), replacingWindowInput.mouseMoved(float, float)for the duration of the capture. The receiver may coalesce by summing. Default: ignored.- Specified by:
mouseDeltain interfaceWindowInput
-
mouseButton
public void mouseButton(int button, boolean pressed, int modifiers, float x, float y, int clickCount) Description copied from interface:WindowInputButton press/release at the given cursor position, with how many presses in a row this is, counted by the backend with the platform's own double-click interval and distance: 1 for a single press, 2 for the second of a double click.0means the backend does not count, and the receiver counts with its own clock.- Specified by:
mouseButtonin interfaceWindowInput
-
scrolled
public void scrolled(float deltaX, float deltaY, float x, float y) Description copied from interface:WindowInputWheel/trackpad scroll; deltas in native notches (positive = up/left).- Specified by:
scrolledin interfaceWindowInput
-
scrolled
public void scrolled(float deltaX, float deltaY, float x, float y, boolean gestureBegins) Description copied from interface:WindowInputA scroll the platform says begins a new gesture: the fingers came down on a trackpad or on a mouse whose surface scrolls, inertia from the gesture before still running or not. A receiver keeps a gesture with the scroller it moved, and only the platform can say where one gesture ends and the next begins while inertia keeps the events coming; a backend that cannot say callsWindowInput.scrolled(float, float, float, float), and the receiver tells gestures apart by the pauses between them.- Specified by:
scrolledin interfaceWindowInput- Parameters:
gestureBegins- whether this event is the first of a new gesture
-
zoomed
public void zoomed(float scale, float x, float y, boolean gestureBegins) Description copied from interface:WindowInputA pinch on a trackpad: a request to zoom around the point by a factor. The backend turns its system's measure into the factor since its previous event: a magnification added to 1, or this event's scale since the gesture began over the previous one's. A system that sends the pinch as the wheel with Control held needs nothing here; the receiver offers that wheel as a zoom itself. A receiver that takes no zoom ignores it.- Specified by:
zoomedin interfaceWindowInput- Parameters:
scale- what to multiply the present size by, positive: above 1 zooms ingestureBegins- whether this event is the first of a new pinch
-
keyEvent
public void keyEvent(int key, int layoutCodePoint, boolean pressed, boolean repeat, int modifiers) Description copied from interface:WindowInputA key went down, repeated or came up.- Specified by:
keyEventin interfaceWindowInput- Parameters:
key- the physical key, aKeysconstantlayoutCodePoint- what the active layout types at that key with no modifier held, as a code point, or0for a key that types nothing; shortcuts are read from itpressed- a press or an auto-repeat rather than a releaserepeat- an auto-repeatmodifiers- theKeys.MOD_*bits held
-
charTyped
public void charTyped(int codepoint) Description copied from interface:WindowInputCommitted text input, one code point (IME/layout-aware, after key events).- Specified by:
charTypedin interfaceWindowInput
-
preeditChanged
Description copied from interface:WindowInputIn-progress IME composition ("preedit") for the focused text input: the still-composing text, its caret, and the stretch of it the input method is converting now (the target the user is choosing a candidate for), shown inline but not yet committed (the commit arrives later viaWindowInput.charTyped(int)). An emptytextclears the composition. Every index is in code points. Default: ignored.What it means, rather than one platform's shape of it: GLFW reports styled blocks and the focused one, SDL a string and a selection; a backend turns either into the target's start and length.
- Specified by:
preeditChangedin interfaceWindowInput- Parameters:
text- the composing text (""clears it)caret- caret position withintexttargetStart- where the stretch being converted starts withintexttargetLength- how long it is;0when nothing is being converted
-
pointerEntered
public void pointerEntered(boolean entered) Description copied from interface:WindowInputCursor entered (true) or left the window's content area.- Specified by:
pointerEnteredin interfaceWindowInput
-
windowResized
public void windowResized(float logicalWidth, float logicalHeight) Description copied from interface:WindowInputWindow content resized (logical points). May be coalesced by the receiver.- Specified by:
windowResizedin interfaceWindowInput
-
filesDropped
Description copied from interface:WindowInputFiles dragged from the OS and dropped on the window, at a point of its content area in logical points: the widget under that point receives them. The point is the platform's where it says one (SDL does), and the pointer's at the drop where it does not (GLFW). Default: ignored.- Specified by:
filesDroppedin interfaceWindowInput- Parameters:
paths- the files, in the order the platform listed themx- where they were dropped, in logical pointsy- where they were dropped, in logical points
-
windowFocusChanged
public void windowFocusChanged(boolean focused) Description copied from interface:WindowInputThe window gained or lost OS input focus. On loss the scene cancels any in-flight press/drag/hover; the matching RELEASE will never arrive (it happens in another app), so it is synthesized. Default: ignored.- Specified by:
windowFocusChangedin interfaceWindowInput
-
windowFullscreenChanged
public void windowFullscreenChanged(boolean fullscreen) Description copied from interface:WindowInputThe window entered (true) or left fullscreen:NativeWindow.isFullscreen()changed its answer. Every change is told once, whoever made it: the application'senterFullscreenandexitFullscreen, and on macOS the person's green button, Control-Command-F or menu item. It is told when the answer changes, which for macOS native fullscreen is when the animation starts rather than when it ends. On the scene it closes a menu, a drop-down list or a calendar that is open in a window of its own, placed against the geometry the change is taking away, and moves a modal dialog's window into the scene.Told even while a modal blocks the window, as a focus change is: the dialog that blocks it is one of the surfaces that has to hear it. Arrives during the native poll, or from inside the call that changed fullscreen, and like the rest of the batch it is acted on when the batch ends. Default: ignored.
- Specified by:
windowFullscreenChangedin interfaceWindowInput
-
inputBatchEnded
public void inputBatchEnded()Description copied from interface:WindowInputEnd of one native poll: dispatch the accumulated batch now.- Specified by:
inputBatchEndedin interfaceWindowInput
-
windowClosed
public void windowClosed()Description copied from interface:WindowInputThe bound window was destroyed. Lets the receiver flush any work that was waiting on a future frame which will now never come, chiefly a window-fade arrival callback (e.g. a dialog completing its result after fading out), since a destroyed window never ticks again. UI thread.- Specified by:
windowClosedin interfaceWindowInput
-