Documentation ¶
Overview ¶
Package button implements a state machine that tracks mouse button clicks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FSM ¶
type FSM struct {
// contains filtered or unexported fields
}
FSM implements a finite-state machine that tracks mouse clicks within an area.
Simplifies tracking of mouse button clicks, i.e. when the caller wants to perform an action only if both the button press and release happen within the specified area.
This object is not thread-safe.
func NewFSM ¶
NewFSM creates a new FSM instance that tracks the state of the specified mouse button through button events that fall within the provided area.
func (*FSM) Event ¶
func (fsm *FSM) Event(m *terminalapi.Mouse) (bool, State)
Event is used to forward mouse events to the state machine. Only events related to the button specified on a call to NewFSM are processed.
Returns a bool indicating if an action guarded by the button should be performed and the state of the button after the provided event. The bool is true if the button click should take an effect, i.e. if the FSM saw both the button click and its release.
func (*FSM) UpdateArea ¶
UpdateArea informs FSM of an area change. This method is idempotent.