mirror of
https://github.com/rivo/tview.git
synced 2025-04-24 13:48:56 +08:00
This commit is contained in:
parent
a2885dd403
commit
0ac5f73025
@ -42,6 +42,11 @@ const (
|
|||||||
MouseScrollDown
|
MouseScrollDown
|
||||||
MouseScrollLeft
|
MouseScrollLeft
|
||||||
MouseScrollRight
|
MouseScrollRight
|
||||||
|
|
||||||
|
// The following special value will not be provided as a mouse action but
|
||||||
|
// indicate that an overridden mouse event was consumed. See
|
||||||
|
// [Box.SetMouseCapture] for details.
|
||||||
|
MouseConsumed
|
||||||
)
|
)
|
||||||
|
|
||||||
// queuedUpdate represented the execution of f queued by
|
// queuedUpdate represented the execution of f queued by
|
||||||
@ -167,7 +172,8 @@ func (a *Application) GetInputCapture() func(event *tcell.EventKey) *tcell.Event
|
|||||||
// the original tcell mouse event and the semantic mouse action) before they are
|
// the original tcell mouse event and the semantic mouse action) before they are
|
||||||
// forwarded to the appropriate mouse event handler. This function can then
|
// forwarded to the appropriate mouse event handler. This function can then
|
||||||
// choose to forward that event (or a different one) by returning it or stop
|
// choose to forward that event (or a different one) by returning it or stop
|
||||||
// the event processing by returning a nil mouse event.
|
// the event processing by returning a nil mouse event. In such a case, the
|
||||||
|
// event is considered consumed and the screen will be redrawn.
|
||||||
func (a *Application) SetMouseCapture(capture func(event *tcell.EventMouse, action MouseAction) (*tcell.EventMouse, MouseAction)) *Application {
|
func (a *Application) SetMouseCapture(capture func(event *tcell.EventMouse, action MouseAction) (*tcell.EventMouse, MouseAction)) *Application {
|
||||||
a.mouseCapture = capture
|
a.mouseCapture = capture
|
||||||
return a
|
return a
|
||||||
|
10
box.go
10
box.go
@ -222,7 +222,11 @@ func (b *Box) WrapMouseHandler(mouseHandler func(MouseAction, *tcell.EventMouse,
|
|||||||
if b.mouseCapture != nil {
|
if b.mouseCapture != nil {
|
||||||
action, event = b.mouseCapture(action, event)
|
action, event = b.mouseCapture(action, event)
|
||||||
}
|
}
|
||||||
if event != nil && mouseHandler != nil {
|
if event == nil {
|
||||||
|
if action == MouseConsumed {
|
||||||
|
consumed = true
|
||||||
|
}
|
||||||
|
} else if mouseHandler != nil {
|
||||||
consumed, capture = mouseHandler(action, event, setFocus)
|
consumed, capture = mouseHandler(action, event, setFocus)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -247,6 +251,10 @@ func (b *Box) MouseHandler() func(action MouseAction, event *tcell.EventMouse, s
|
|||||||
// returning a nil mouse event, in which case the default handler will not be
|
// returning a nil mouse event, in which case the default handler will not be
|
||||||
// called.
|
// called.
|
||||||
//
|
//
|
||||||
|
// When a nil event is returned, the returned mouse action value may be set to
|
||||||
|
// [MouseConsumed] to indicate that the event was consumed and the screen should
|
||||||
|
// be redrawn. Any other value will not cause a redraw.
|
||||||
|
//
|
||||||
// Providing a nil handler will remove a previously existing handler.
|
// Providing a nil handler will remove a previously existing handler.
|
||||||
//
|
//
|
||||||
// Note that mouse events are ignored completely if the application has not been
|
// Note that mouse events are ignored completely if the application has not been
|
||||||
|
Loading…
x
Reference in New Issue
Block a user