Changed the API for scrolling
This commit is contained in:
parent
43696543d8
commit
c57c8acba7
@ -63,6 +63,12 @@ func (application *Application) OnMouseMove (
|
||||
application.callbackManager.onMouseMove = onMouseMove
|
||||
}
|
||||
|
||||
func (application *Application) OnScroll (
|
||||
onScroll func (x, y int),
|
||||
) {
|
||||
application.callbackManager.onScroll = onScroll
|
||||
}
|
||||
|
||||
func (application *Application) OnStart (
|
||||
onStart func (),
|
||||
) {
|
||||
|
@ -68,14 +68,28 @@ func (backend *Backend) handleButtonPress (
|
||||
event xevent.ButtonPressEvent,
|
||||
) {
|
||||
buttonEvent := *event.ButtonPressEvent
|
||||
if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 {
|
||||
switch buttonEvent.Detail {
|
||||
case 4:
|
||||
backend.callbackManager.RunScroll(0, -1)
|
||||
case 5:
|
||||
backend.callbackManager.RunScroll(0, 1)
|
||||
case 6:
|
||||
backend.callbackManager.RunScroll(-1, 0)
|
||||
case 7:
|
||||
backend.callbackManager.RunScroll(1, 0)
|
||||
}
|
||||
} else {
|
||||
backend.callbackManager.RunPress(stone.Button(buttonEvent.Detail + 127))
|
||||
}
|
||||
}
|
||||
|
||||
func (backend *Backend) handleButtonRelease (
|
||||
connection *xgbutil.XUtil,
|
||||
event xevent.ButtonReleaseEvent,
|
||||
) {
|
||||
buttonEvent := *event.ButtonReleaseEvent
|
||||
if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 { return }
|
||||
backend.callbackManager.RunRelease(stone.Button(buttonEvent.Detail + 127))
|
||||
}
|
||||
|
||||
|
6
event.go
6
event.go
@ -6,6 +6,7 @@ type CallbackManager struct {
|
||||
onRelease func (button Button)
|
||||
onResize func ()
|
||||
onMouseMove func (x, y int)
|
||||
onScroll func (x, y int)
|
||||
onStart func ()
|
||||
}
|
||||
|
||||
@ -34,6 +35,11 @@ func (manager *CallbackManager) RunMouseMove (x, y int) {
|
||||
manager.onMouseMove(x, y)
|
||||
}
|
||||
|
||||
func (manager *CallbackManager) RunScroll (x, y int) {
|
||||
if manager.onScroll == nil { return }
|
||||
manager.onScroll(x, y)
|
||||
}
|
||||
|
||||
func (manager *CallbackManager) RunStart () {
|
||||
if manager.onStart == nil { return }
|
||||
manager.onStart()
|
||||
|
4
input.go
4
input.go
@ -52,10 +52,6 @@ const (
|
||||
MouseButtonLeft Button = MouseButton1
|
||||
MouseButtonMiddle Button = MouseButton2
|
||||
MouseButtonRight Button = MouseButton3
|
||||
MouseButtonScrollUp Button = MouseButton4
|
||||
MouseButtonScrollDown Button = MouseButton5
|
||||
MouseButtonScrollLeft Button = MouseButton6
|
||||
MouseButtonScrollRight Button = MouseButton7
|
||||
MouseButtonBack Button = MouseButton8
|
||||
MouseButtonForward Button = MouseButton9
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user