Class InputEvent

GoDiagram®
v10.0.12
by Northwoods Software®

An InputEvent represents a mouse or keyboard or touch event.

Inheritance
InputEvent
Namespace: Northwoods.Go
Assembly: Northwoods.GoDiagram.Avalonia.dll
Syntax
public class InputEvent
Remarks

The principal properties hold information about a particular input event. These properties include the DocumentPoint at which a mouse event occurred in document coordinates, the corresponding point in view/element coordinates, ViewPoint, the Key for keyboard events, and the Modifiers and Button at the time. Additional descriptive properties include ClickCount, Delta, Timestamp, and the source event Event (if available).

Many of its properties are provided for convenient access to the state of the input event, such as asking whether the Control key was held down at the time, or the TargetElement (a GraphObject) that the mouse was over .

When real events fire on the Diagram, InputEvents are created automatically set update the value of LastInput. These events set the value of Event with the backing browser-defined Event, which may be a MouseEvent, KeyboardEvent, PointerEvent, TouchEvent, and so on.

InputEvents backed by MouseEvents set both Button, the button that caused the action, and Buttons, the set of buttons currently pressed after the action has happened. By default a user-created InputEvent sets Button and Buttons as if the event was a left-click.

You can create InputEvents and set the value of LastInput in order to simulate user actions in tools.

Constructors

InputEvent()

The InputEvent class constructor produces an empty InputEvent.

Declaration
public InputEvent()
Remarks

You should never need to call this constructor. But if you do, you must first set Diagram to the Diagram before any other use.

InputEvent(InputEvent)

Make a copy of an InputEvent.

Declaration
public InputEvent(InputEvent evt)
Parameters
Type Name Description
InputEvent evt

Properties

Alt

Gets or sets whether the alt key is being held down.

Declaration
public bool Alt { get; set; }
Property Value
Type Description
bool
Remarks

This is true if the key was pressed at the time of the event.

See Also

Button

Gets or sets the numerical value representing the mouse button that caused this event.

Declaration
public double Button { get; set; }
Property Value
Type Description
double
Remarks

Only one mouse button can cause an event at a time, but the set of all buttons currently pressed is kept in Buttons.

This property describes nothing during a mousemove event, since no button press causes the event. Instead, use the convenience properties Left, Middle, or Right, or use the value of Buttons to determine which mouse buttons are held during mousemove events.

Common values for this property:

  • 0: left mouse button
  • 1: middle mouse button
  • 2: right mouse button

Other values are possible if the mouse has additional buttons.

If there is no associated Event, setting this also sets the Buttons flags to only this button.

This property is valid if this is a mouse event.

See Also

Buttons

Gets or sets the set of buttons that are currently being held down.

Declaration
public long Buttons { get; set; }
Property Value
Type Description
long
Remarks

If this is a mouseup event, this set of buttons does not include the button that was just released, which will be the value of Button.

Common values for this property:

  • 0: not holding down any button
  • 1: left mouse button
  • 2: right mouse button
  • 3: both left and right mouse buttons
  • 4: middle mouse button
  • 5: middle and left mouse buttons
  • 6: middle and right mouse buttons
  • 7: all three common mouse buttons

Other values are possible if the mouse has additional buttons.

This property is valid if this is a mouse event.

See Also

ClickCount

Gets or sets whether this event represents a click or a double-click.

Declaration
public double ClickCount { get; set; }
Property Value
Type Description
double
Remarks

It is zero if not a click; one if a single-click; two if a double-click. This property is valid if this is a mouse event.

Control

Gets or sets whether the control key is being held down.

Declaration
public bool Control { get; set; }
Property Value
Type Description
bool
Remarks

This is true if the key was pressed at the time of the event.

See Also

Delta

Gets or sets the amount of change associated with a mouse-wheel rotation.

Declaration
public double Delta { get; set; }
Property Value
Type Description
double
Remarks

It is an abstract double, either positive or negative. This property is valid if this is a mouse-wheel event.

Diagram

Gets or sets the source diagram associated with the event.

Declaration
public Diagram Diagram { get; set; }
Property Value
Type Description
Diagram

DocumentPoint

Gets or sets the point at which this input event occurred, in document coordinates.

Declaration
public Point DocumentPoint { get; set; }
Property Value
Type Description
Point
Remarks

The Point is in document coordinates, the same as the Position for Parts in the diagram. This should be valid for mouse events. For keyboard events, this is the last available mouse point.

See Also

Down

Gets or sets whether the InputEvent represents a mouse-down or a key-down event.

Declaration
public bool Down { get; set; }
Property Value
Type Description
bool
Remarks

The default value is false.

Event

Gets or sets the platform's user-agent-supplied event for this event.

Declaration
public object Event { get; set; }
Property Value
Type Description
object
Remarks

It may be null if no underlying event exists.

See Also

Handled

Gets or sets whether an InputEvent that applies to a GraphObject and bubbles up the chain of containing Panels is stopped from continuing up the chain.

Declaration
public bool Handled { get; set; }
Property Value
Type Description
bool
Remarks

Some event handlers may set this to true to avoid getting any behavior from the containing Panels. The default value is false.

IsMultiTouch

This property is true when the InputEvent is caused by a touch event that registered more than one touch.

Declaration
public bool IsMultiTouch { get; set; }
Property Value
Type Description
bool
See Also

IsTouchEvent

This read-only property is true when the InputEvent is caused by a touch event.

Declaration
public bool IsTouchEvent { get; }
Property Value
Type Description
bool
See Also

Key

Gets or sets the key pressed or released as this event. If it is a letter, the value is the uppercase version.

Declaration
public string Key { get; set; }
Property Value
Type Description
string
Remarks

This property is valid if this is a keyboard event.

Left

Gets or sets whether the logical left mouse button is being held down.

Declaration
public bool Left { get; set; }
Property Value
Type Description
bool
Remarks

This is true if the button was pressed at the time of the event.

If this InputEvent was a "mouseup" or "mousedown", this property uses the value of Button. Otherwise, it uses the value of Buttons.

When setting, this sets the value of Buttons.

See Also

Meta

Gets or sets whether the meta key is being held down.

Declaration
public bool Meta { get; set; }
Property Value
Type Description
bool
Remarks

This is true if the key was pressed at the time of the event.

See Also

Middle

Gets or sets whether the logical middle mouse button is being held down.

Declaration
public bool Middle { get; set; }
Property Value
Type Description
bool
Remarks

This is true if the button was pressed at the time of the event.

See Also

Modifiers

Gets or sets the modifier keys that were used with the mouse or keyboard event.

Declaration
public int Modifiers { get; set; }
Property Value
Type Description
int
Remarks

The int will be a combination of flags representing Control, Shift, Alt or Meta.

See Also

Right

Gets or sets whether the logical right mouse button is being held down.

Declaration
public bool Right { get; set; }
Property Value
Type Description
bool
Remarks

This is true if the button was pressed at the time of the event.

See Also

Shift

Gets or sets whether the shift key is being held down.

Declaration
public bool Shift { get; set; }
Property Value
Type Description
bool
Remarks

This is true if the key was pressed at the time of the event.

See Also

TargetDiagram

Gets or sets the diagram associated with the canvas that the event is currently targeting.

Declaration
public Diagram TargetDiagram { get; set; }
Property Value
Type Description
Diagram

TargetElement

Gets or sets the GraphObject that is at the current mouse point, if any.

Declaration
public GraphObject TargetElement { get; set; }
Property Value
Type Description
GraphObject
Remarks

For those events that are bubbled up the chain of parent Panels, this property provides access to the original GraphObject where the input event occurred.

See Also

Timestamp

Gets or sets the time at which the event occurred, in milliseconds.

Declaration
public DateTime Timestamp { get; set; }
Property Value
Type Description
DateTime

Up

Gets or sets whether the InputEvent represents a mouse-up or a key-up event.

Declaration
public bool Up { get; set; }
Property Value
Type Description
bool
Remarks

The default value is false.

ViewPoint

Gets or sets the point at which this input event occurred.

Declaration
public Point ViewPoint { get; set; }
Property Value
Type Description
Point
Remarks

The Point is in view coordinates within the viewport, not in document coordinates. This should be valid for mouse events. For keyboard events, this is the last available mouse point.

See Also