widget

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewButton

func NewButton(label string, onClicked func()) *gtk.Button

Types

type DropDown[T any] struct {
	gtk.Widgetter
	gtools.Factoryer[T]
	*gtools.Model[T]

	OnSelected func(T)
	// contains filtered or unexported fields
}

func NewDropDown

func NewDropDown[T any](
	items []T,
	setup gtools.FactorySetup,
	bind gtools.FactoryBind[T],
) *DropDown[T]
type DropDownVar[T any] struct {
	gtk.Widgetter
	gtools.Factoryer[T]
	*gtools.ModelVar[T]

	OnSelected func(T)
	// contains filtered or unexported fields
}

func NewDropDownVar

func NewDropDownVar[T any](
	items *[]T,
	setup gtools.FactorySetup,
	bind gtools.FactoryBind[T],
) *DropDownVar[T]

type List

type List[T any] struct {
	*gtk.ListView

	*TemplateView[T, *gtk.ListView]
}
Example
items := []string{"1", "2", "3"}
list := widget.NewList(
	items,
	gtools.SelectionMultiple,
	func(listitem gtools.ListItem) {
		listitem.SetChild(gtk.NewLabel(""))
	},
	func(listitem gtools.ListItem, obj string) {
		listitem.Child().(*gtk.Label).SetText(obj)
	},
)

list.ConnectMultipleSelected(func(indexes []int) {
	for _, i := range indexes {
		fmt.Printf("|%s|", list.At(i))
	}
	fmt.Println()
})
list.ConnectSelected(func(index int) {
	fmt.Println(list.At(index))
})
Output:

func NewList

func NewList[T any](
	items []T,
	smodel gtools.ListSelectionMode,
	setup gtools.FactorySetup,
	bind gtools.FactoryBind[T],
) *List[T]

type ListVar

type ListVar[T any] struct {
	*gtk.ListView
	*TemplateView[T, *gtk.ListView]
}

func NewListVar

func NewListVar[T any](
	items *[]T,
	smodel gtools.ListSelectionMode,
	setup gtools.FactorySetup,
	bind gtools.FactoryBind[T],
) *ListVar[T]

type TemplateView

type TemplateView[T any, M gtools.SetModelFactoryer] struct {
	gtools.Modeller[T]
	gtools.Factoryer[T]
	gtools.Selectioner

	Setter M
}

func NewTemplateView

func NewTemplateView[T any, M gtools.SetModelFactoryer](
	smodel gtools.ListSelectionMode,
	sm M,
	setup gtools.FactorySetup,
	bind gtools.FactoryBind[T],
	modeller gtools.Modeller[T],
) *TemplateView[T, M]

func (*TemplateView[T, M]) InitSetter

func (m *TemplateView[T, M]) InitSetter()

func (*TemplateView[T, _]) Refresh

func (m *TemplateView[T, _]) Refresh()

Refreshes absolutely everything. To be more specific here is the list of what it refreshes:

- Refreshes List.Items

- Refreshes the model

I generally discourage its use and prefer to refresh things as they are modified manually and individually.

func (*TemplateView[T, _]) SetSelectionMode

func (m *TemplateView[T, _]) SetSelectionMode(mode gtools.ListSelectionMode)

Jump to

Keyboard shortcuts

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