Compare commits
	
		
			2 Commits
		
	
	
		
			43ec7a0311
			...
			e4857da22d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| e4857da22d | |||
| 114cbb346d | 
							
								
								
									
										16
									
								
								button.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								button.go
									
									
									
									
									
								
							@ -89,23 +89,23 @@ func (this *Button) applyLayout () {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Button) handleKeyDown (key input.Key, numberPad bool) bool {
 | 
					func (this *Button) handleKeyDown (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) handleKeyUp (key input.Key, numberPad bool) bool {
 | 
					 | 
				
			||||||
	if key != input.KeyEnter && key != input.Key(' ') { return false }
 | 
					 | 
				
			||||||
	this.on.click.Broadcast()
 | 
						this.on.click.Broadcast()
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *Button) handleKeyUp (key input.Key, numberPad bool) bool {
 | 
				
			||||||
 | 
						if !isClickingKey(key) { return false }
 | 
				
			||||||
 | 
						return true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Button) handleButtonDown (button input.Button) bool {
 | 
					func (this *Button) handleButtonDown (button input.Button) bool {
 | 
				
			||||||
	if button != input.ButtonLeft { return false }
 | 
						if !isClickingButton(button) { return false }
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Button) handleButtonUp (button input.Button) bool {
 | 
					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()) {
 | 
						if this.Window().MousePosition().In(this.Bounds()) {
 | 
				
			||||||
		this.on.click.Broadcast()
 | 
							this.on.click.Broadcast()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -54,23 +54,23 @@ func (this *Checkbox) OnValueChange (callback func ()) event.Cookie {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Checkbox) handleKeyDown (key input.Key, numberPad bool) bool {
 | 
					func (this *Checkbox) handleKeyDown (key input.Key, numberPad bool) bool {
 | 
				
			||||||
	if key != input.KeyEnter && key != input.Key(' ') { return false }
 | 
						if !isClickingKey(key) { return false }
 | 
				
			||||||
	this.Toggle()
 | 
						this.Toggle()
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Checkbox) handleKeyUp (key input.Key, numberPad bool) bool {
 | 
					func (this *Checkbox) handleKeyUp (key input.Key, numberPad bool) bool {
 | 
				
			||||||
	if key != input.KeyEnter && key != input.Key(' ') { return false}
 | 
						if !isClickingKey(key) { return false}
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Checkbox) handleButtonDown (button input.Button) bool {
 | 
					func (this *Checkbox) handleButtonDown (button input.Button) bool {
 | 
				
			||||||
	if button != input.ButtonLeft { return false }
 | 
						if !isClickingButton(button) { return false }
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Checkbox) handleButtonUp (button input.Button) bool {
 | 
					func (this *Checkbox) handleButtonUp (button input.Button) bool {
 | 
				
			||||||
	if button != input.ButtonLeft { return false }
 | 
						if !isClickingButton(button) { return false }
 | 
				
			||||||
	if this.Window().MousePosition().In(this.Bounds()) {
 | 
						if this.Window().MousePosition().In(this.Bounds()) {
 | 
				
			||||||
		this.Toggle()
 | 
							this.Toggle()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										33
									
								
								dropdown.go
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								dropdown.go
									
									
									
									
									
								
							@ -66,6 +66,17 @@ func (this *Dropdown) SetItems (items ...string) {
 | 
				
			|||||||
	this.items = items
 | 
						this.items = items
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Choose creates a menu that allows the user to pick a value.
 | 
				
			||||||
 | 
					func (this *Dropdown) Choose () {
 | 
				
			||||||
 | 
						if this.menu != nil {
 | 
				
			||||||
 | 
							this.menu.Close()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						menu, err := NewAnchoredMenu(this, this.itemList()...)
 | 
				
			||||||
 | 
						if err != nil { return }
 | 
				
			||||||
 | 
						this.menu = menu
 | 
				
			||||||
 | 
						menu.SetVisible(true)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Dropdown) itemList () []tomo.Object {
 | 
					func (this *Dropdown) itemList () []tomo.Object {
 | 
				
			||||||
	items := make([]tomo.Object, len(this.items))
 | 
						items := make([]tomo.Object, len(this.items))
 | 
				
			||||||
	for index, value := range this.items {
 | 
						for index, value := range this.items {
 | 
				
			||||||
@ -80,36 +91,26 @@ func (this *Dropdown) itemList () []tomo.Object {
 | 
				
			|||||||
	return items
 | 
						return items
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Dropdown) showMenu () {
 | 
					 | 
				
			||||||
	if this.menu != nil {
 | 
					 | 
				
			||||||
		this.menu.Close()
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	menu, err := NewAnchoredMenu(this, this.itemList()...)
 | 
					 | 
				
			||||||
	if err != nil { return }
 | 
					 | 
				
			||||||
	this.menu = menu
 | 
					 | 
				
			||||||
	menu.SetVisible(true)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (this *Dropdown) handleKeyDown (key input.Key, numberPad bool) bool {
 | 
					func (this *Dropdown) handleKeyDown (key input.Key, numberPad bool) bool {
 | 
				
			||||||
	if key != input.KeyEnter && key != input.Key(' ') { return false }
 | 
						if !isClickingKey(key) { return false }
 | 
				
			||||||
 | 
						this.Choose()
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Dropdown) handleKeyUp (key input.Key, numberPad bool) bool {
 | 
					func (this *Dropdown) handleKeyUp (key input.Key, numberPad bool) bool {
 | 
				
			||||||
	if key != input.KeyEnter && key != input.Key(' ') { return false }
 | 
						if !isClickingKey(key) { return false }
 | 
				
			||||||
	this.showMenu()
 | 
					 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Dropdown) handleButtonDown (button input.Button) bool {
 | 
					func (this *Dropdown) handleButtonDown (button input.Button) bool {
 | 
				
			||||||
	if button != input.ButtonLeft { return false }
 | 
						if !isClickingButton(button) { return false }
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Dropdown) handleButtonUp (button input.Button) bool {
 | 
					func (this *Dropdown) handleButtonUp (button input.Button) bool {
 | 
				
			||||||
	if button != input.ButtonLeft { return false }
 | 
						if !isClickingButton(button) { return false }
 | 
				
			||||||
	if this.Window().MousePosition().In(this.Bounds()) {
 | 
						if this.Window().MousePosition().In(this.Bounds()) {
 | 
				
			||||||
		this.showMenu()
 | 
							this.Choose()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										19
									
								
								input.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								input.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					package objects
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "git.tebibyte.media/tomo/tomo/input"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func isClickingKey (key input.Key) bool {
 | 
				
			||||||
 | 
						return key == input.KeyEnter || key == input.Key(' ')
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func isConfirmationKey (key input.Key) bool {
 | 
				
			||||||
 | 
						return key == input.KeyEnter
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func isClickingButton (button input.Button) bool {
 | 
				
			||||||
 | 
						return button == input.ButtonLeft
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func isMenuButton (button input.Button) bool {
 | 
				
			||||||
 | 
						return button == input.ButtonLeft
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -55,12 +55,12 @@ func (this *LabelCheckbox) OnValueChange (callback func ()) event.Cookie {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *LabelCheckbox) handleButtonDown (button input.Button) bool {
 | 
					func (this *LabelCheckbox) handleButtonDown (button input.Button) bool {
 | 
				
			||||||
	if button != input.ButtonLeft { return false }
 | 
						if !isClickingButton(button) { return false }
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *LabelCheckbox) handleButtonUp (button input.Button) bool {
 | 
					func (this *LabelCheckbox) handleButtonUp (button input.Button) bool {
 | 
				
			||||||
	if button != input.ButtonLeft { return false }
 | 
						if !isClickingButton(button) { return false }
 | 
				
			||||||
	if this.Window().MousePosition().In(this.Bounds()) {
 | 
						if this.Window().MousePosition().In(this.Bounds()) {
 | 
				
			||||||
		this.checkbox.SetFocused(true)
 | 
							this.checkbox.SetFocused(true)
 | 
				
			||||||
		this.checkbox.Toggle()
 | 
							this.checkbox.Toggle()
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										16
									
								
								swatch.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								swatch.go
									
									
									
									
									
								
							@ -171,23 +171,23 @@ func (this *Swatch) userSetValue (value color.Color) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Swatch) handleKeyDown (key input.Key, numberPad bool) bool {
 | 
					func (this *Swatch) handleKeyDown (key input.Key, numberPad bool) bool {
 | 
				
			||||||
	if key != input.KeyEnter && key != input.Key(' ') { return false }
 | 
						if !isClickingKey(key) { return false }
 | 
				
			||||||
	return true
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (this *Swatch) handleKeyUp (key input.Key, numberPad bool) bool {
 | 
					 | 
				
			||||||
	if key != input.KeyEnter && key != input.Key(' ') { return false }
 | 
					 | 
				
			||||||
	this.Choose()
 | 
						this.Choose()
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *Swatch) handleKeyUp (key input.Key, numberPad bool) bool {
 | 
				
			||||||
 | 
						if !isClickingKey(key) { return false }
 | 
				
			||||||
 | 
						return true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Swatch) handleButtonDown (button input.Button) bool {
 | 
					func (this *Swatch) handleButtonDown (button input.Button) bool {
 | 
				
			||||||
	if button != input.ButtonLeft { return false }
 | 
						if !isClickingButton(button) { return false }
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Swatch) handleButtonUp (button input.Button) bool {
 | 
					func (this *Swatch) handleButtonUp (button input.Button) bool {
 | 
				
			||||||
	if button != input.ButtonLeft { return false }
 | 
						if !isClickingButton(button) { return false }
 | 
				
			||||||
	if this.Window().MousePosition().In(this.Bounds()) {
 | 
						if this.Window().MousePosition().In(this.Bounds()) {
 | 
				
			||||||
		this.Choose()
 | 
							this.Choose()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -87,7 +87,7 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) bool {
 | 
				
			|||||||
	} ()
 | 
						} ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case key == input.KeyEnter:
 | 
						case isConfirmationKey(key):
 | 
				
			||||||
		this.on.confirm.Broadcast()
 | 
							this.on.confirm.Broadcast()
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	case key == input.KeyBackspace:
 | 
						case key == input.KeyBackspace:
 | 
				
			||||||
@ -114,7 +114,7 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) bool {
 | 
				
			|||||||
func (this *TextInput) handleKeyUp (key input.Key, numpad bool) bool {
 | 
					func (this *TextInput) handleKeyUp (key input.Key, numpad bool) bool {
 | 
				
			||||||
	modifiers := this.Window().Modifiers()
 | 
						modifiers := this.Window().Modifiers()
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case key == input.KeyEnter:
 | 
						case isConfirmationKey(key):
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	case key == input.KeyBackspace:
 | 
						case key == input.KeyBackspace:
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user