Class JtvEvent
public class JtvEvent
Core event record passed to every handleEvent method in the view tree.
JtvEvent plays a fundamental role in JT Vision's event-handling
strategy. Both outside events (mouse and keyboard) and command events
generated by communicating views are stored and transmitted as TEvent
instances.
The what field identifies which kind of event occurred and,
therefore, which of the three payload objects (mouse,
keyDown, or message) carries the relevant data:
- Mouse events (EventCodes.evMouse mask) —
mouseis populated. - Keyboard events (EventCodes.evKeyDown) —
keyDownis populated. - Message events (EventCodes.evMessage mask, including
EventCodes.evCommand and EventCodes.evBroadcast) —
messageis populated. - Nothing events (EventCodes.evNothing) — the event has been handled and should be ignored.
This class is the Java equivalent of the Pascal TEvent variant
record defined in DRIVERS.TPU. Because Java does not support
variant records, the three payload types are held as separate objects that
are always present; only the one indicated by what carries meaningful
data.
org.viktor44.jtvision.core.JtvEvent
Summary
Constructors
| Visibility | Signature |
|---|---|
| public | JtvEvent() |
Fields
| Modifiers | Field name | Type |
|---|---|---|
| private | what | int |
| private | mouse | org.viktor44.jtvision.core.MouseEvent |
| private | keyDown | org.viktor44.jtvision.core.KeyDownEvent |
| private | message | org.viktor44.jtvision.core.MessageEvent |
Methods
| Modifiers | Method signature | Return type |
|---|---|---|
| public | setKeyDownEvent(int keyCode, int controlKeyState, char keyChar) | void |
| public | setPasteEvent(String text) | void |
| public | setCommand(int command, Object infoPtr) | void |
| public | setBroadcast(int command, Object infoPtr) | void |
| public | copyFrom(JtvEvent other) | void |
| public | getWhat() | int |
| public | setWhat(int what) | void |
| public | getMouse() | org.viktor44.jtvision.core.MouseEvent |
| public | setMouse(MouseEvent mouse) | void |
| public | getKeyDown() | org.viktor44.jtvision.core.KeyDownEvent |
| public | getMessage() | org.viktor44.jtvision.core.MessageEvent |
| public | setMessage(MessageEvent message) | void |
Constructors
JtvEvent()
No method description provided
Fields
int what
Event type discriminator (What in the original Pascal record).
The numeric value describes the kind of event that occurred. Use the constants in EventCodes to interpret this field. Masks such as EventCodes.evMouse and EventCodes.evMessage let callers check the event family without enumerating every individual type:
if ((event.getWhat() & evMouse) != 0) { ... }
When a view finishes handling an event it calls clearEvent,
which resets this field to EventCodes.evNothing. All views
should silently ignore events whose what equals
evNothing.
org.viktor44.jtvision.core.MouseEvent mouse
Mouse event payload (Buttons, Double/EventFlags,
and Where in the original Pascal record).
Valid when what matches the EventCodes.evMouse mask.
org.viktor44.jtvision.core.KeyDownEvent keyDown
Keyboard event payload (KeyCode / CharCode +
ScanCode in the original Pascal record).
Valid when what equals EventCodes.evKeyDown.
org.viktor44.jtvision.core.MessageEvent message
Message event payload (Command and InfoPtr /
InfoLong / … in the original Pascal record).
Valid when what matches the EventCodes.evMessage mask,
i.e. for EventCodes.evCommand and EventCodes.evBroadcast
events.
Methods
setKeyDownEvent(int keyCode, int controlKeyState, char keyChar)
Fills this event as a key-down event.
Sets what to EventCodes.evKeyDown and populates the
keyboard payload.
Parameters
keyCode- full 16-bit key code (high byte = scan code, low byte = character code)controlKeyState- platform-specific modifier key statekeyChar- Unicode character produced by the key press, orKeyEvent.CHAR_UNDEFINEDfor non-printable keys
setPasteEvent(String text)
Fills this event as a bracketed-paste event.
Sets what to EventCodes.evPaste and stores the pasted
text in the message payload's infoPtr field. Receivers should
cast getMessage().getInfoPtr() to String.
Parameters
text- the clipboard text delivered by the terminal's bracketed-paste sequence
setCommand(int command, Object infoPtr)
Fills this event as a command event.
Sets what to EventCodes.evCommand and populates the
message payload. Command events are directed to the focused view first
and travel up the view tree until handled.
Parameters
command- the command code (seeCommandCodes)infoPtr- optional object payload, ornull
setBroadcast(int command, Object infoPtr)
Fills this event as a broadcast event.
Sets what to EventCodes.evBroadcast and populates the
message payload. Broadcast events are delivered to every view in the
current group, regardless of focus.
Parameters
command- the broadcast command code (seeCommandCodes)infoPtr- optional object payload, ornull
copyFrom(JtvEvent other)
Copies all fields from another event into this instance.
After this call this event is an independent copy of other;
subsequent changes to other do not affect this instance.
Parameters
other- the source event to copy from
getWhat()
Event type discriminator (What in the original Pascal record).
The numeric value describes the kind of event that occurred. Use the constants in EventCodes to interpret this field. Masks such as EventCodes.evMouse and EventCodes.evMessage let callers check the event family without enumerating every individual type:
if ((event.getWhat() & evMouse) != 0) { ... }
When a view finishes handling an event it calls clearEvent,
which resets this field to EventCodes.evNothing. All views
should silently ignore events whose what equals
evNothing.
setWhat(int what)
Event type discriminator (What in the original Pascal record).
The numeric value describes the kind of event that occurred. Use the constants in EventCodes to interpret this field. Masks such as EventCodes.evMouse and EventCodes.evMessage let callers check the event family without enumerating every individual type:
if ((event.getWhat() & evMouse) != 0) { ... }
When a view finishes handling an event it calls clearEvent,
which resets this field to EventCodes.evNothing. All views
should silently ignore events whose what equals
evNothing.
Parameters
what
getMouse()
Mouse event payload (Buttons, Double/EventFlags,
and Where in the original Pascal record).
Valid when what matches the EventCodes.evMouse mask.
setMouse(MouseEvent mouse)
Mouse event payload (Buttons, Double/EventFlags,
and Where in the original Pascal record).
Valid when what matches the EventCodes.evMouse mask.
Parameters
mouse
getKeyDown()
Keyboard event payload (KeyCode / CharCode +
ScanCode in the original Pascal record).
Valid when what equals EventCodes.evKeyDown.
getMessage()
Message event payload (Command and InfoPtr /
InfoLong / … in the original Pascal record).
Valid when what matches the EventCodes.evMessage mask,
i.e. for EventCodes.evCommand and EventCodes.evBroadcast
events.
setMessage(MessageEvent message)
Message event payload (Command and InfoPtr /
InfoLong / … in the original Pascal record).
Valid when what matches the EventCodes.evMessage mask,
i.e. for EventCodes.evCommand and EventCodes.evBroadcast
events.
Parameters
message