Tidied up documentation on Propagator
This commit is contained in:
		
							parent
							
								
									6bb5b2d79c
								
							
						
					
					
						commit
						b6eb158964
					
				@ -23,7 +23,9 @@ type Propagator struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// NewPropagator creates a new event propagator that uses the specified iterator
 | 
					// NewPropagator creates a new event propagator that uses the specified iterator
 | 
				
			||||||
// to access a list of child elements that will have events propagated to them.
 | 
					// to access a list of child elements that will have events propagated to them.
 | 
				
			||||||
 | 
					// If iterator is nil, the function will return nil.
 | 
				
			||||||
func NewPropagator (iterator ChildIterator) (propagator *Propagator) {
 | 
					func NewPropagator (iterator ChildIterator) (propagator *Propagator) {
 | 
				
			||||||
 | 
						if iterator == nil { return nil }
 | 
				
			||||||
	propagator = &Propagator {
 | 
						propagator = &Propagator {
 | 
				
			||||||
		iterator: iterator,
 | 
							iterator: iterator,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -32,69 +34,88 @@ func NewPropagator (iterator ChildIterator) (propagator *Propagator) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Focused returns whether or not this element or any of its children
 | 
					// Focused returns whether or not this element or any of its children
 | 
				
			||||||
// are currently focused.
 | 
					// are currently focused.
 | 
				
			||||||
func (propagator *Propagator) Focused () (focused bool)
 | 
					func (propagator *Propagator) Focused () (focused bool) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Focus focuses this element, if its parent element grants the
 | 
					// Focus focuses this element, if its parent element grants the
 | 
				
			||||||
// request.
 | 
					// request.
 | 
				
			||||||
func (propagator *Propagator) Focus ()
 | 
					func (propagator *Propagator) Focus () {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// HandleFocus causes this element to mark itself as focused. If the
 | 
					// HandleFocus causes this element to mark itself as focused. If the
 | 
				
			||||||
// element does not have children, it is disabled, or there are no more
 | 
					// element does not have children or there are no more focusable children in
 | 
				
			||||||
// selectable children in the given direction, it should return false
 | 
					// the given direction, it should return false and do nothing. Otherwise, it
 | 
				
			||||||
// and do nothing. Otherwise, it should select itself and any children
 | 
					// marks itself as focused along with any applicable children and returns
 | 
				
			||||||
// (if applicable) and return true.
 | 
					// true.
 | 
				
			||||||
func (propagator *Propagator) HandleFocus (direction input.KeynavDirection) (accepted bool)
 | 
					func (propagator *Propagator) HandleFocus (direction input.KeynavDirection) (accepted bool) {
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
// HandleDeselection causes this element to mark itself and all of its
 | 
					}
 | 
				
			||||||
// children as unfocused.
 | 
					 | 
				
			||||||
func (propagator *Propagator) HandleUnfocus ()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// OnFocusRequest sets a function to be called when this element wants
 | 
					// HandleDeselection causes this element to mark itself and all of its children
 | 
				
			||||||
// its parent element to focus it. Parent elements should return true if
 | 
					// as unfocused.
 | 
				
			||||||
// the request was granted, and false if it was not. If the parent
 | 
					func (propagator *Propagator) HandleUnfocus () {
 | 
				
			||||||
// element returns true, the element must act as if a HandleFocus call
 | 
					 | 
				
			||||||
// was made with KeynavDirectionNeutral.
 | 
					 | 
				
			||||||
func (propagator *Propagator) OnFocusRequest (func () (granted bool))
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
// OnFocusMotionRequest sets a function to be called when this
 | 
					}
 | 
				
			||||||
// element wants its parent element to focus the element behind or in
 | 
					 | 
				
			||||||
// front of it, depending on the specified direction. Parent elements
 | 
					 | 
				
			||||||
// should return true if the request was granted, and false if it was
 | 
					 | 
				
			||||||
// not.
 | 
					 | 
				
			||||||
func (propagator *Propagator) OnFocusMotionRequest (func (direction input.KeynavDirection) (granted bool))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// HandleKeyDown is called when a key is pressed down or repeated while
 | 
					// OnFocusRequest sets a function to be called when this element wants its
 | 
				
			||||||
// this element has keyboard focus. It is important to note that not
 | 
					// parent element to focus it. Parent elements should return true if the request
 | 
				
			||||||
// every key down event is guaranteed to be paired with exactly one key
 | 
					// was granted, and false if it was not. If the parent element returns true, the
 | 
				
			||||||
// up event. This is the reason a list of modifier keys held down at the
 | 
					// element acts as if a HandleFocus call was made with KeynavDirectionNeutral.
 | 
				
			||||||
// time of the key press is given.
 | 
					func (propagator *Propagator) OnFocusRequest (func () (granted bool)) {
 | 
				
			||||||
func (propagator *Propagator) HandleKeyDown (key input.Key, modifiers input.Modifiers)
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
// HandleKeyUp is called when a key is released while this element has
 | 
					}
 | 
				
			||||||
// keyboard focus.
 | 
					 | 
				
			||||||
func (propagator *Propagator) HandleKeyUp (key input.Key, modifiers input.Modifiers)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// HandleMouseDown is called when a mouse button is pressed down on this
 | 
					// OnFocusMotionRequest sets a function to be called when this element wants its
 | 
				
			||||||
// element.
 | 
					// parent element to focus the element behind or in front of it, depending on
 | 
				
			||||||
func (propagator *Propagator) HandleMouseDown (x, y int, button input.Button)
 | 
					// the specified direction. Parent elements should return true if the request
 | 
				
			||||||
 | 
					// was granted, and false if it was not.
 | 
				
			||||||
 | 
					func (propagator *Propagator) OnFocusMotionRequest (func (direction input.KeynavDirection) (granted bool)) {
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
// HandleMouseUp is called when a mouse button is released that was
 | 
					}
 | 
				
			||||||
// originally pressed down on this element.
 | 
					 | 
				
			||||||
func (propagator *Propagator) HandleMouseUp (x, y int, button input.Button)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// HandleMouseMove is called when the mouse is moved over this element,
 | 
					// HandleKeyDown propogates the keyboard event to the currently selected child.
 | 
				
			||||||
// or the mouse is moving while being held down and originally pressed
 | 
					func (propagator *Propagator) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
 | 
				
			||||||
// down on this element.
 | 
					 | 
				
			||||||
func (propagator *Propagator) HandleMouseMove (x, y int)
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
// HandleScroll is called when the mouse is scrolled. The X and Y
 | 
					}
 | 
				
			||||||
// direction of the scroll event are passed as deltaX and deltaY.
 | 
					 | 
				
			||||||
func (propagator *Propagator) HandleMouseScroll (x, y int, deltaX, deltaY float64)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SetTheme sets the element's theme to something fulfilling the
 | 
					// HandleKeyUp propogates the keyboard event to the currently selected child.
 | 
				
			||||||
// theme.Theme interface.
 | 
					func (propagator *Propagator) HandleKeyUp (key input.Key, modifiers input.Modifiers) {
 | 
				
			||||||
func (propagator *Propagator) SetTheme (theme.Theme)
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
// SetConfig sets the element's configuration to something fulfilling
 | 
					}
 | 
				
			||||||
// the config.Config interface.
 | 
					
 | 
				
			||||||
func (propagator *Propagator) SetConfig (config.Config)
 | 
					// HandleMouseDown propagates the mouse event to the element under the mouse
 | 
				
			||||||
 | 
					// pointer.
 | 
				
			||||||
 | 
					func (propagator *Propagator) HandleMouseDown (x, y int, button input.Button) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// HandleMouseUp propagates the mouse event to the element that the released
 | 
				
			||||||
 | 
					// mouse button was originally pressed on.
 | 
				
			||||||
 | 
					func (propagator *Propagator) HandleMouseUp (x, y int, button input.Button) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// HandleMouseMove propagates the mouse event to the element that was last
 | 
				
			||||||
 | 
					// pressed down by the mouse if the mouse is currently being held down, else it
 | 
				
			||||||
 | 
					// propagates the event to whichever element is underneath the mouse pointer.
 | 
				
			||||||
 | 
					func (propagator *Propagator) HandleMouseMove (x, y int) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// HandleScroll propagates the mouse event to the element under the mouse
 | 
				
			||||||
 | 
					// pointer.
 | 
				
			||||||
 | 
					func (propagator *Propagator) HandleMouseScroll (x, y int, deltaX, deltaY float64) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SetTheme sets the theme of all children to the specified theme.
 | 
				
			||||||
 | 
					func (propagator *Propagator) SetTheme (theme.Theme) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SetConfig sets the theme of all children to the specified config.
 | 
				
			||||||
 | 
					func (propagator *Propagator) SetConfig (config.Config) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user