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
|
application.callbackManager.onMouseMove = onMouseMove
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (application *Application) OnScroll (
|
||||||
|
onScroll func (x, y int),
|
||||||
|
) {
|
||||||
|
application.callbackManager.onScroll = onScroll
|
||||||
|
}
|
||||||
|
|
||||||
func (application *Application) OnStart (
|
func (application *Application) OnStart (
|
||||||
onStart func (),
|
onStart func (),
|
||||||
) {
|
) {
|
||||||
|
@ -68,7 +68,20 @@ func (backend *Backend) handleButtonPress (
|
|||||||
event xevent.ButtonPressEvent,
|
event xevent.ButtonPressEvent,
|
||||||
) {
|
) {
|
||||||
buttonEvent := *event.ButtonPressEvent
|
buttonEvent := *event.ButtonPressEvent
|
||||||
backend.callbackManager.RunPress(stone.Button(buttonEvent.Detail + 127))
|
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 (
|
func (backend *Backend) handleButtonRelease (
|
||||||
@ -76,6 +89,7 @@ func (backend *Backend) handleButtonRelease (
|
|||||||
event xevent.ButtonReleaseEvent,
|
event xevent.ButtonReleaseEvent,
|
||||||
) {
|
) {
|
||||||
buttonEvent := *event.ButtonReleaseEvent
|
buttonEvent := *event.ButtonReleaseEvent
|
||||||
|
if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 { return }
|
||||||
backend.callbackManager.RunRelease(stone.Button(buttonEvent.Detail + 127))
|
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)
|
onRelease func (button Button)
|
||||||
onResize func ()
|
onResize func ()
|
||||||
onMouseMove func (x, y int)
|
onMouseMove func (x, y int)
|
||||||
|
onScroll func (x, y int)
|
||||||
onStart func ()
|
onStart func ()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +35,11 @@ func (manager *CallbackManager) RunMouseMove (x, y int) {
|
|||||||
manager.onMouseMove(x, y)
|
manager.onMouseMove(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (manager *CallbackManager) RunScroll (x, y int) {
|
||||||
|
if manager.onScroll == nil { return }
|
||||||
|
manager.onScroll(x, y)
|
||||||
|
}
|
||||||
|
|
||||||
func (manager *CallbackManager) RunStart () {
|
func (manager *CallbackManager) RunStart () {
|
||||||
if manager.onStart == nil { return }
|
if manager.onStart == nil { return }
|
||||||
manager.onStart()
|
manager.onStart()
|
||||||
|
4
input.go
4
input.go
@ -52,10 +52,6 @@ const (
|
|||||||
MouseButtonLeft Button = MouseButton1
|
MouseButtonLeft Button = MouseButton1
|
||||||
MouseButtonMiddle Button = MouseButton2
|
MouseButtonMiddle Button = MouseButton2
|
||||||
MouseButtonRight Button = MouseButton3
|
MouseButtonRight Button = MouseButton3
|
||||||
MouseButtonScrollUp Button = MouseButton4
|
|
||||||
MouseButtonScrollDown Button = MouseButton5
|
|
||||||
MouseButtonScrollLeft Button = MouseButton6
|
|
||||||
MouseButtonScrollRight Button = MouseButton7
|
|
||||||
MouseButtonBack Button = MouseButton8
|
MouseButtonBack Button = MouseButton8
|
||||||
MouseButtonForward Button = MouseButton9
|
MouseButtonForward Button = MouseButton9
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user