MouseMsg class
Message sent for mouse events.
Contains information about:
- The action (press, release, motion, wheel)
- Which button was involved
- The position in the terminal (column, row)
- Modifier keys held during the event
Example
@override
(Model, Cmd?) update(Msg msg) {
return switch (msg) {
MouseMsg(action: MouseAction.press, button: MouseButton.left, :final x, :final y) =>
(handleClick(x, y), null),
MouseMsg(action: MouseAction.wheel, button: MouseButton.wheelUp) =>
(scrollUp(), null),
MouseMsg(action: MouseAction.wheel, button: MouseButton.wheelDown) =>
(scrollDown(), null),
_ => (this, null),
};
}
Constructors
- MouseMsg({required MouseAction action, required MouseButton button, required int x, required int y, bool ctrl = false, bool alt = false, bool shift = false})
-
Creates a mouse message.
const
Properties
- action → MouseAction
-
The type of mouse action.
final
- alt → bool
-
Whether Alt was held.
final
-
The mouse button involved.
final
- ctrl → bool
-
Whether Ctrl was held.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- hasModifier → bool
-
Whether any modifier key is held.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shift → bool
-
Whether Shift was held.
final
- x → int
-
The column position (0-based).
final
- y → int
-
The row position (0-based).
final
Methods
-
copyWith(
{MouseAction? action, MouseButton? button, int? x, int? y, bool? ctrl, bool? alt, bool? shift}) → MouseMsg - Creates a copy of this message with some fields replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override