Skip to content

Commit

Permalink
Fixed modifier keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Ray committed Jun 23, 2020
1 parent 5cd30d5 commit 9a166d4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ func (ui *UI) Destroy() {
// NewFrame Call this at the beginning of the frame to tell the UI that the frame has started
func (ui *UI) NewFrame() {
ui.timer = time.Now()

ui.io.SetDisplaySize(pixelVecToimguiVec(ui.win.Bounds().Size()))

ui.io.AddMouseWheelDelta(float32(ui.win.MouseScroll().X), float32(ui.win.MouseScroll().Y))
mouse := ui.matrix.Unproject(ui.win.MousePosition())
ui.io.SetMousePosition(imgui.Vec2{X: float32(mouse.X), Y: float32(mouse.Y)})

ui.io.SetMouseButtonDown(0, ui.win.Pressed(pixelgl.MouseButtonLeft))
ui.io.SetMouseButtonDown(1, ui.win.Pressed(pixelgl.MouseButtonRight))
ui.io.SetMouseButtonDown(2, ui.win.Pressed(pixelgl.MouseButtonMiddle))
ui.io.AddInputCharacters(ui.win.Typed())

for _, key := range keys {
if ui.win.Pressed(key) {
Expand All @@ -110,15 +112,17 @@ func (ui *UI) NewFrame() {
}
ui.updateKeyMod()
}
ui.io.AddInputCharacters(ui.win.Typed())

imgui.NewFrame()
}

func (ui *UI) mapModifier(lKey pixelgl.Button, rKey pixelgl.Button) (lResult int, rResult int) {
if ui.win.Pressed(lKey) {
lResult = 1
lResult = int(lKey)
}
if ui.win.Pressed(rKey) {
rResult = 1
rResult = int(rKey)
}
return
}
Expand Down Expand Up @@ -393,5 +397,13 @@ var keys = []pixelgl.Button{
pixelgl.KeyKPAdd,
pixelgl.KeyKPEnter,
pixelgl.KeyKPEqual,
pixelgl.KeyLeftShift,
pixelgl.KeyLeftControl,
pixelgl.KeyLeftAlt,
pixelgl.KeyLeftSuper,
pixelgl.KeyRightShift,
pixelgl.KeyRightControl,
pixelgl.KeyRightAlt,
pixelgl.KeyRightSuper,
pixelgl.KeyMenu,
}

0 comments on commit 9a166d4

Please sign in to comment.