controls

package
v0.3.1-0...-ca91996 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetFocusHolder

func SetFocusHolder(holder FocusHolder)

Types

type Dropdown struct {

	// Controller is the adapter for events generated from this component.
	// if nil, events that would be passed to the controller will not be handled.
	Controller DropdownController

	Disabled askew.BoolValue

	CurIndex int
	// contains filtered or unexported fields
}

Dropdown is a DOM component autogenerated by Askew

func NewDropdown

func NewDropdown(kind SelectorKind, indicator IndicatorKind, caption string) *Dropdown

NewDropdown creates a new Dropdown and initializes it.

func (d *Dropdown) AddItem(name string, selected bool)

AddItem adds an item of the given name to the dropdown list.

func (o *Dropdown) Destroy()

Destroy destroys this element (and all contained components). If it is currently inserted anywhere, it gets removed before.

func (o *Dropdown) Extract()

Extract removes this component from its current parent. The component will be in initial state afterwards.

func (o *Dropdown) FirstNode() js.Value

FirstNode returns the first DOM node of this component. It implements the askew.Component interface.

func (d *Dropdown) FocusLeaving()

FocusLeaving implements controls.FocusHolder and is called when the focus leaves this dropdown.

func (d *Dropdown) Init(kind SelectorKind, indicator IndicatorKind, caption string)

Init initializes the Dropdown.

func (o *Dropdown) InsertInto(parent js.Value, before js.Value)

InsertInto inserts this component into the given object. The component will be in inserted state afterwards.

The component will be inserted in front of 'before', or at the end if 'before' is 'js.Undefined()'.

func (d *Dropdown) Root() js.Value

Root implements controls.FocusHolder and returns the root list element that contains the dropdown list.

func (d *Dropdown) SetItem(index int, value bool)

SetItem sets the value of an item. For single-select dropdowns, this does nothing for value == false (to unselect the current item, select another one or -1 for SelectAtMostOne dropdowns).

type DropdownController interface {
	ItemClicked(index int) bool
}

DropdownController can be implemented to handle external events generated by Dropdown

type DropdownList struct {
	DefaultController DropdownController
	// contains filtered or unexported fields
}

DropdownList is a list of Dropdown whose manipulation methods auto-update the corresponding nodes in the document.

func (l *DropdownList) Append(item *Dropdown)

Append appends the given item to the list.

func (l *DropdownList) Destroy(index int)

Destroy destroys the item at the given index and removes it from the list.

func (l *DropdownList) DestroyAll()

DestroyAll destroys all items in the list and empties it.

func (l *DropdownList) Init(container js.Value, index int)

Init initializes the list, discarding previous data. The list's items will be placed in the given container, starting at the given index.

func (l *DropdownList) Insert(index int, item *Dropdown)

Insert inserts the given item at the given index into the list.

func (l *DropdownList) Item(index int) *Dropdown

Item returns the item at the current index.

func (l *DropdownList) Len() int

Len returns the number of items in the list.

func (l *DropdownList) Remove(index int) *Dropdown

Remove removes the item at the given index from the list and returns it.

type FocusHolder

type FocusHolder interface {
	// Root returns the root element of the component.
	Root() js.Value
	// FocusLeaving is called when the focus is leaving the root element, but
	// before the focus has actually left.
	FocusLeaving()
}

FocusHolder is a UI component that needs to react when the focus leaves its root element.

type IndicatorKind

type IndicatorKind int

IndicatorKind defines what kind of indicator is displayed in front of a menu item depending on its selection status.

const (
	// SelectionIndicator shows a general „selected“ icon if the item is selected.
	SelectionIndicator IndicatorKind = iota
	// VisibilityIndicator shows a visibility icon if the item is selected.
	VisibilityIndicator
	// InvisibilityIndicator shows an invisibility icon if the item is deselected.
	InvisibilityIndicator
)

type OptionalDropdown

type OptionalDropdown struct {
	DefaultController DropdownController
	// contains filtered or unexported fields
}

OptionalDropdown is a nillable embeddable container for Dropdown.

func (*OptionalDropdown) Init

func (o *OptionalDropdown) Init(container js.Value, index int)

Init initializes the container to be empty. The contained item, if any, will be placed in the given container at the given index.

func (*OptionalDropdown) Item

func (o *OptionalDropdown) Item() *Dropdown

Item returns the current item, or nil if no item is assigned

func (*OptionalDropdown) Remove

func (o *OptionalDropdown) Remove() askew.Component

Remove removes the current item and returns it. Returns nil if there is no current item.

func (*OptionalDropdown) Set

func (o *OptionalDropdown) Set(value *Dropdown)

Set sets the contained item destroying the current one. Give nil as value to simply destroy the current item.

type OptionalPopupBase

type OptionalPopupBase struct {
	// contains filtered or unexported fields
}

OptionalPopupBase is a nillable embeddable container for PopupBase.

func (*OptionalPopupBase) Init

func (o *OptionalPopupBase) Init(container js.Value, index int)

Init initializes the container to be empty. The contained item, if any, will be placed in the given container at the given index.

func (*OptionalPopupBase) Item

func (o *OptionalPopupBase) Item() *PopupBase

Item returns the current item, or nil if no item is assigned

func (*OptionalPopupBase) Remove

func (o *OptionalPopupBase) Remove() askew.Component

Remove removes the current item and returns it. Returns nil if there is no current item.

func (*OptionalPopupBase) Set

func (o *OptionalPopupBase) Set(value *PopupBase)

Set sets the contained item destroying the current one. Give nil as value to simply destroy the current item.

type OptionalSwitch

type OptionalSwitch struct {
	DefaultController SwitchController
	// contains filtered or unexported fields
}

OptionalSwitch is a nillable embeddable container for Switch.

func (*OptionalSwitch) Init

func (o *OptionalSwitch) Init(container js.Value, index int)

Init initializes the container to be empty. The contained item, if any, will be placed in the given container at the given index.

func (*OptionalSwitch) Item

func (o *OptionalSwitch) Item() *Switch

Item returns the current item, or nil if no item is assigned

func (*OptionalSwitch) Remove

func (o *OptionalSwitch) Remove() askew.Component

Remove removes the current item and returns it. Returns nil if there is no current item.

func (*OptionalSwitch) Set

func (o *OptionalSwitch) Set(value *Switch)

Set sets the contained item destroying the current one. Give nil as value to simply destroy the current item.

type OptionaldropdownItem

type OptionaldropdownItem struct {
	DefaultController dropdownItemController
	// contains filtered or unexported fields
}

OptionaldropdownItem is a nillable embeddable container for dropdownItem.

func (*OptionaldropdownItem) Init

func (o *OptionaldropdownItem) Init(container js.Value, index int)

Init initializes the container to be empty. The contained item, if any, will be placed in the given container at the given index.

func (*OptionaldropdownItem) Item

func (o *OptionaldropdownItem) Item() *dropdownItem

Item returns the current item, or nil if no item is assigned

func (*OptionaldropdownItem) Remove

func (o *OptionaldropdownItem) Remove() askew.Component

Remove removes the current item and returns it. Returns nil if there is no current item.

func (*OptionaldropdownItem) Set

func (o *OptionaldropdownItem) Set(value *dropdownItem)

Set sets the contained item destroying the current one. Give nil as value to simply destroy the current item.

type OptionalpopupInput

type OptionalpopupInput struct {
	// contains filtered or unexported fields
}

OptionalpopupInput is a nillable embeddable container for popupInput.

func (*OptionalpopupInput) Init

func (o *OptionalpopupInput) Init(container js.Value, index int)

Init initializes the container to be empty. The contained item, if any, will be placed in the given container at the given index.

func (*OptionalpopupInput) Item

func (o *OptionalpopupInput) Item() *popupInput

Item returns the current item, or nil if no item is assigned

func (*OptionalpopupInput) Remove

func (o *OptionalpopupInput) Remove() askew.Component

Remove removes the current item and returns it. Returns nil if there is no current item.

func (*OptionalpopupInput) Set

func (o *OptionalpopupInput) Set(value *popupInput)

Set sets the contained item destroying the current one. Give nil as value to simply destroy the current item.

type OptionalpopupTemplateItem

type OptionalpopupTemplateItem struct {
	// contains filtered or unexported fields
}

OptionalpopupTemplateItem is a nillable embeddable container for popupTemplateItem.

func (*OptionalpopupTemplateItem) Init

func (o *OptionalpopupTemplateItem) Init(container js.Value, index int)

Init initializes the container to be empty. The contained item, if any, will be placed in the given container at the given index.

func (*OptionalpopupTemplateItem) Item

func (o *OptionalpopupTemplateItem) Item() *popupTemplateItem

Item returns the current item, or nil if no item is assigned

func (*OptionalpopupTemplateItem) Remove

Remove removes the current item and returns it. Returns nil if there is no current item.

func (*OptionalpopupTemplateItem) Set

func (o *OptionalpopupTemplateItem) Set(value *popupTemplateItem)

Set sets the contained item destroying the current one. Give nil as value to simply destroy the current item.

type OptionalpopupTemplateList

type OptionalpopupTemplateList struct {
	// contains filtered or unexported fields
}

OptionalpopupTemplateList is a nillable embeddable container for popupTemplateList.

func (*OptionalpopupTemplateList) Init

func (o *OptionalpopupTemplateList) Init(container js.Value, index int)

Init initializes the container to be empty. The contained item, if any, will be placed in the given container at the given index.

func (*OptionalpopupTemplateList) Item

func (o *OptionalpopupTemplateList) Item() *popupTemplateList

Item returns the current item, or nil if no item is assigned

func (*OptionalpopupTemplateList) Remove

Remove removes the current item and returns it. Returns nil if there is no current item.

func (*OptionalpopupTemplateList) Set

func (o *OptionalpopupTemplateList) Set(value *popupTemplateList)

Set sets the contained item destroying the current one. Give nil as value to simply destroy the current item.

type OptionalpopupText

type OptionalpopupText struct {
	// contains filtered or unexported fields
}

OptionalpopupText is a nillable embeddable container for popupText.

func (*OptionalpopupText) Init

func (o *OptionalpopupText) Init(container js.Value, index int)

Init initializes the container to be empty. The contained item, if any, will be placed in the given container at the given index.

func (*OptionalpopupText) Item

func (o *OptionalpopupText) Item() *popupText

Item returns the current item, or nil if no item is assigned

func (*OptionalpopupText) Remove

func (o *OptionalpopupText) Remove() askew.Component

Remove removes the current item and returns it. Returns nil if there is no current item.

func (*OptionalpopupText) Set

func (o *OptionalpopupText) Set(value *popupText)

Set sets the contained item destroying the current one. Give nil as value to simply destroy the current item.

type PopupBase

type PopupBase struct {
	Display       askew.StringValue
	Visibility    askew.StringValue
	Title         askew.StringValue
	CancelCaption askew.StringValue

	ConfirmCaption askew.StringValue

	Content askew.GenericOptional
	// contains filtered or unexported fields
}

PopupBase is a DOM component autogenerated by Askew

func NewPopupBase

func NewPopupBase() *PopupBase

NewPopupBase creates a new component and initializes it with the given parameters.

func (*PopupBase) Confirm

func (pb *PopupBase) Confirm(text string, cb func())

Confirm shows the popup and calls cb if the user clicks OK.

func (*PopupBase) Destroy

func (o *PopupBase) Destroy()

Destroy destroys this element (and all contained components). If it is currently inserted anywhere, it gets removed before.

func (*PopupBase) ErrorMsg

func (pb *PopupBase) ErrorMsg(text string, cb func())

ErrorMsg shows the popup containing the given text titled as 'Error'. Calls cb after the user dismisses the message.

func (*PopupBase) Extract

func (o *PopupBase) Extract()

Extract removes this component from its current parent. The component will be in initial state afterwards.

func (*PopupBase) FirstNode

func (o *PopupBase) FirstNode() js.Value

FirstNode returns the first DOM node of this component. It implements the askew.Component interface.

func (*PopupBase) Init

func (o *PopupBase) Init()

Init initializes the component with the given arguments.

func (*PopupBase) InsertInto

func (o *PopupBase) InsertInto(parent js.Value, before js.Value)

InsertInto inserts this component into the given object. The component will be in inserted state afterwards.

The component will be inserted in front of 'before', or at the end if 'before' is 'js.Undefined()'.

func (*PopupBase) Show

func (pb *PopupBase) Show(title string, content PopupContent, confirmCaption, cancelCaption string)

Show shows the given content inside the popup. Calling show does not block; you are responsible for awaiting for user confirmation or cancellation via the Cancel() / Confirm() callbacks of the content.

func (*PopupBase) TextInput

func (pb *PopupBase) TextInput(title, label string, cb func(input string))

TextInput shows the popup and calls the callback with the entered string if the user clicks OK.

type PopupBaseList

type PopupBaseList struct {
	// contains filtered or unexported fields
}

PopupBaseList is a list of PopupBase whose manipulation methods auto-update the corresponding nodes in the document.

func (*PopupBaseList) Append

func (l *PopupBaseList) Append(item *PopupBase)

Append appends the given item to the list.

func (*PopupBaseList) Destroy

func (l *PopupBaseList) Destroy(index int)

Destroy destroys the item at the given index and removes it from the list.

func (*PopupBaseList) DestroyAll

func (l *PopupBaseList) DestroyAll()

DestroyAll destroys all items in the list and empties it.

func (*PopupBaseList) Init

func (l *PopupBaseList) Init(container js.Value, index int)

Init initializes the list, discarding previous data. The list's items will be placed in the given container, starting at the given index.

func (*PopupBaseList) Insert

func (l *PopupBaseList) Insert(index int, item *PopupBase)

Insert inserts the given item at the given index into the list.

func (*PopupBaseList) Item

func (l *PopupBaseList) Item(index int) *PopupBase

Item returns the item at the current index.

func (*PopupBaseList) Len

func (l *PopupBaseList) Len() int

Len returns the number of items in the list.

func (*PopupBaseList) Remove

func (l *PopupBaseList) Remove(index int) *PopupBase

Remove removes the item at the given index from the list and returns it.

type PopupContent

type PopupContent interface {
	askew.Component
	Cancel()
	Confirm()
	DoShow()
	NeedsDoShow() bool
}

PopupContent supplies the content of the popup and implements its controller.

type SelectorKind

type SelectorKind int

SelectorKind defines how items in a dropdown menu are selected.

const (
	// SelectAtMostOne is like SelectOne but adds an additional item „None“ to the
	// list of selectable items.
	SelectAtMostOne SelectorKind = iota
	// SelectOne is used when selecting a new item unselects the previous one.
	SelectOne
	// SelectMultiple is used when multiple items can be selected at the same time.
	SelectMultiple
)

type Switch

type Switch struct {

	// Controller is the adapter for events generated from this component.
	// if nil, events that would be passed to the controller will not be handled.
	Controller SwitchController
	Value      askew.BoolValue
	// contains filtered or unexported fields
}

Switch is a DOM component autogenerated by Askew

func NewSwitch

func NewSwitch() *Switch

NewSwitch creates a new component and initializes it with the given parameters.

func (*Switch) Destroy

func (o *Switch) Destroy()

Destroy destroys this element (and all contained components). If it is currently inserted anywhere, it gets removed before.

func (*Switch) Extract

func (o *Switch) Extract()

Extract removes this component from its current parent. The component will be in initial state afterwards.

func (*Switch) FirstNode

func (o *Switch) FirstNode() js.Value

FirstNode returns the first DOM node of this component. It implements the askew.Component interface.

func (*Switch) Init

func (o *Switch) Init()

Init initializes the component with the given arguments.

func (*Switch) InsertInto

func (o *Switch) InsertInto(parent js.Value, before js.Value)

InsertInto inserts this component into the given object. The component will be in inserted state afterwards.

The component will be inserted in front of 'before', or at the end if 'before' is 'js.Undefined()'.

type SwitchController

type SwitchController interface {
	Swapped()
}

SwitchController can be implemented to handle external events generated by Switch

type SwitchList

type SwitchList struct {
	DefaultController SwitchController
	// contains filtered or unexported fields
}

SwitchList is a list of Switch whose manipulation methods auto-update the corresponding nodes in the document.

func (*SwitchList) Append

func (l *SwitchList) Append(item *Switch)

Append appends the given item to the list.

func (*SwitchList) Destroy

func (l *SwitchList) Destroy(index int)

Destroy destroys the item at the given index and removes it from the list.

func (*SwitchList) DestroyAll

func (l *SwitchList) DestroyAll()

DestroyAll destroys all items in the list and empties it.

func (*SwitchList) Init

func (l *SwitchList) Init(container js.Value, index int)

Init initializes the list, discarding previous data. The list's items will be placed in the given container, starting at the given index.

func (*SwitchList) Insert

func (l *SwitchList) Insert(index int, item *Switch)

Insert inserts the given item at the given index into the list.

func (*SwitchList) Item

func (l *SwitchList) Item(index int) *Switch

Item returns the item at the current index.

func (*SwitchList) Len

func (l *SwitchList) Len() int

Len returns the number of items in the list.

func (*SwitchList) Remove

func (l *SwitchList) Remove(index int) *Switch

Remove removes the item at the given index from the list and returns it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL