Use key/button functions for menu

This commit is contained in:
Sasha Koshka 2024-08-24 14:32:19 -04:00
parent 0ccdb609ef
commit 8469962c90

View File

@ -92,20 +92,20 @@ func (this *Menu) newTearLine () tomo.Object {
tearLine.SetRole(tomo.R("objects", "TearLine")) tearLine.SetRole(tomo.R("objects", "TearLine"))
tearLine.SetFocusable(true) tearLine.SetFocusable(true)
tearLine.OnKeyDown(func (key input.Key, numberPad bool) bool { tearLine.OnKeyDown(func (key input.Key, numberPad bool) bool {
if key != input.KeyEnter && key != input.Key(' ') { return false } if !isClickingKey(key) { return false }
return true return true
}) })
tearLine.OnKeyUp(func (key input.Key, numberPad bool) bool { tearLine.OnKeyUp(func (key input.Key, numberPad bool) bool {
if key != input.KeyEnter && key != input.Key(' ') { return false } if !isClickingKey(key) { return false }
this.TearOff() this.TearOff()
return true return true
}) })
tearLine.OnButtonDown(func (button input.Button) bool { tearLine.OnButtonDown(func (button input.Button) bool {
if button != input.ButtonLeft { return false } if !isClickingButton(button) { return false }
return true return true
}) })
tearLine.OnButtonUp(func (button input.Button) bool { tearLine.OnButtonUp(func (button input.Button) bool {
if button != input.ButtonLeft { return false } if !isClickingButton(button) { return false }
if tearLine.Window().MousePosition().In(tearLine.Bounds()) { if tearLine.Window().MousePosition().In(tearLine.Bounds()) {
this.TearOff() this.TearOff()
} }