NAME
Term::Fabulous::Event::MouseMove - The mouse pointer moved with no button held
SYNOPSIS
$canvas->on( MouseMove => sub ($event) {
my ( $column, $row ) = $canvas->cell_at($event);
$status->text("pointer over $column,$row");
return;
} );
DESCRIPTION
Term::Fabulous fires a MouseMove event every time the terminal reports that the pointer moved while no mouse button was held, while "run" in Term::Fabulous is active and mouse input is enabled (the mouse parameter of "new" in Term::Fabulous, on by default except in inline mode). Moves with a button held are drags and fire Mouse (Term::Fabulous::Event::Mouse) instead.
Like Mouse, the event is fired on the topmost widget that painted the cell under the pointer in the last frame (see "MOUSE" in Term::Fabulous::Manual::Events), or on the root widget when there is none, and then bubbles up to the ancestors. Term::Fabulous also records the new pointer position before it fires the event, so the hover state of the widgets (OnHoverStart, OnHoverStopped, is_hovered) follows the pointer with the next frame.
Terminals report moves generously, often for every cell the pointer crosses, so keep MouseMove listeners cheap.
The class is a subclass of Clay::UI::Events::Event, so target, current_target, name ('MouseMove' unless given to the constructor) and bubble_mode (IF_CONTINUE) are available as well.
CONSTRUCTOR
new
my $event = Term::Fabulous::Event::MouseMove->new( x => 10, y => 3 );
Programs rarely build these events themselves; it is useful in tests. Unknown parameters die. Besides the parameters below, the name and bubble_mode parameters of Clay::UI::Events::Event are accepted.
x-
Required. The column of the pointer, counted from 0 at the left edge of the terminal.
y-
Required. The row of the pointer, counted from 0 at the top edge of the terminal.
modifiers-
Optional. A bit mask of
TB_MOD_SHIFT,TB_MOD_ALT,TB_MOD_CTRLandTB_MOD_MOTION. Default:0.
of
my $event = Term::Fabulous::Event::MouseMove->of($termbox_event);
Builds an event from a Term::Fabulous::Termbox::Event: x, y and modifiers from its x, y and mod. Called by Term::Fabulous; class method.
METHODS
x
my $column = $event->x;
The column of the cell under the pointer, from 0 at the left edge of the terminal. To get a position inside a canvas, use "cell_at" in Term::Fabulous::Widget::Canvas or "pixel_at" in Term::Fabulous::Widget::PixelCanvas; both accept this event.
y
my $row = $event->y;
The row of the cell under the pointer, from 0 at the top edge of the terminal.
modifiers
my $with_shift = $event->modifiers & TB_MOD_SHIFT;
A bit mask of the modifier keys held while the pointer moved: TB_MOD_SHIFT, TB_MOD_ALT, TB_MOD_CTRL from Term::Fabulous::Termbox. TB_MOD_MOTION is always set for an event Term::Fabulous fires, since the pointer moved.
SEE ALSO
"MOUSE" in Term::Fabulous::Manual::Events, Term::Fabulous::Event::Mouse, Term::Fabulous, Clay::UI::Events::Event.