diff options
author | Jeffas <dev@jeffas.io> | 2019-09-05 23:32:36 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-09-11 11:41:34 -0400 |
commit | f6216bb6213a15cdcdf50089f3c4a8e9a30d9337 (patch) | |
tree | 3075b68379ae7c13cb9eedc53b7cf033672478a9 /lib/ui/interfaces.go | |
parent | a441e3b3a55d11e7cc9444298051ff339d1b7519 (diff) | |
download | aerc-f6216bb6213a15cdcdf50089f3c4a8e9a30d9337.tar.gz |
Add Mouseable
This adds the Mouseable interface. When this is implemented for a component that item can accept and process mouseevents. At the top level when a mouse event is received it is passed to the grid's handler and then it trickles down until it reaches a component that can actually handle it, such as the tablist, dirlist or msglist. A mouse event is passed so that components can handle other things such as scrolling with the mousewheel. The components themselves then perform the necessary actions. Clicking emails in the messagelist opens them in a new tab. Textinputs can be clicked to position the cursor inside them. Mouseevents are not forwarded to the terminal at the moment. Elements which do not handle mouse events are not required to implement the Mouseable interface.
Diffstat (limited to 'lib/ui/interfaces.go')
-rw-r--r-- | lib/ui/interfaces.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/ui/interfaces.go b/lib/ui/interfaces.go index 2f63424..9e79571 100644 --- a/lib/ui/interfaces.go +++ b/lib/ui/interfaces.go @@ -50,9 +50,18 @@ type Container interface { Children() []Drawable } -// A drawable that can be clicked -type Clickable interface { +type MouseHandler interface { + // Handle a mouse event which occurred at the local x and y positions + MouseEvent(localX int, localY int, event tcell.Event) +} + +// A drawable that can be interacted with by the mouse +type Mouseable interface { Drawable + MouseHandler +} - MouseEvent(event tcell.Event) +type MouseableDrawableInteractive interface { + DrawableInteractive + MouseHandler } |