Functions to check for common buttons/keys

This commit is contained in:
2024-08-16 16:15:52 -04:00
parent 114cbb346d
commit e4857da22d
7 changed files with 52 additions and 32 deletions

View File

@@ -89,23 +89,23 @@ func (this *Button) applyLayout () {
}
func (this *Button) handleKeyDown (key input.Key, numberPad bool) bool {
if key != input.KeyEnter && key != input.Key(' ') { return false }
if !isClickingKey(key) { return false }
this.on.click.Broadcast()
return true
}
func (this *Button) handleKeyUp (key input.Key, numberPad bool) bool {
if key != input.KeyEnter && key != input.Key(' ') { return false }
if !isClickingKey(key) { return false }
return true
}
func (this *Button) handleButtonDown (button input.Button) bool {
if button != input.ButtonLeft { return false }
if !isClickingButton(button) { return false }
return true
}
func (this *Button) handleButtonUp (button input.Button) bool {
if button != input.ButtonLeft { return false }
if !isClickingButton(button) { return false }
if this.Window().MousePosition().In(this.Bounds()) {
this.on.click.Broadcast()
}