26 lines
602 B
Go
26 lines
602 B
Go
package base
|
|
|
|
// WithFocus is a base component that implements the Focusable interface
|
|
type WithFocus struct {
|
|
focus bool
|
|
}
|
|
|
|
// SetFocus - Set the focus value on this component
|
|
func (f *WithFocus) SetFocus(value bool) {
|
|
f.focus = value
|
|
}
|
|
|
|
// Focus - focus this component, syntactic sugar for f.SetFocus(true)
|
|
func (f *WithFocus) Focus() {
|
|
f.SetFocus(true)
|
|
}
|
|
|
|
// Unfocus - unfocus this component, syntactic sugar for f.SetFocus(false)
|
|
func (f *WithFocus) Unfocus() {
|
|
f.SetFocus(false)
|
|
}
|
|
|
|
// HasFocus - Returns true if this component has focus.
|
|
func (f WithFocus) HasFocus() bool {
|
|
return f.focus
|
|
}
|