Skip to content

Commit

Permalink
Adding mousescroll override
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Ray committed Jun 27, 2020
1 parent 27fc54d commit 1f8688c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions input.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pixelui

import (
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
"github.com/inkyblackness/imgui-go"
)
Expand Down Expand Up @@ -45,6 +46,16 @@ func (ui *UI) inputWant(button pixelgl.Button) bool {
return ui.io.WantCaptureKeyboard()
}

// MouseScroll returns the mouse scroll amount if imgui does not want the mouse
// (if mouse is not hovering an imgui element)
func (ui *UI) MouseScroll() pixel.Vec {
if ui.io.WantCaptureMouse() {
return pixel.ZV
}

return ui.win.MouseScroll()
}

// JustPressed returns true if imgui hasn't handled the button and the button was just pressed
func (ui *UI) JustPressed(button pixelgl.Button) bool {
return !ui.inputWant(button) && ui.win.JustPressed(button)
Expand Down

0 comments on commit 1f8688c

Please sign in to comment.