Skip to main content

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:

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​

VisibilitySignature
publicJtvEvent()

Fields​

ModifiersField nameType
privatewhatint
privatemouseorg.viktor44.jtvision.core.MouseEvent
privatekeyDownorg.viktor44.jtvision.core.KeyDownEvent
privatemessageorg.viktor44.jtvision.core.MessageEvent

Methods​

ModifiersMethod signatureReturn type
publicsetKeyDownEvent(int keyCode, int controlKeyState, char keyChar)void
publicsetPasteEvent(String text)void
publicsetCommand(int command, Object infoPtr)void
publicsetBroadcast(int command, Object infoPtr)void
publiccopyFrom(JtvEvent other)void
publicgetWhat()int
publicsetWhat(int what)void
publicgetMouse()org.viktor44.jtvision.core.MouseEvent
publicsetMouse(MouseEvent mouse)void
publicgetKeyDown()org.viktor44.jtvision.core.KeyDownEvent
publicgetMessage()org.viktor44.jtvision.core.MessageEvent
publicsetMessage(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 state
  • keyChar - Unicode character produced by the key press, or KeyEvent.CHAR_UNDEFINED for 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 (see CommandCodes)
  • infoPtr - optional object payload, or null

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 (see CommandCodes)
  • infoPtr - optional object payload, or null

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