functions

OnClick
Edited: Sunday 25 January 2026

OnClick

Category: Utilities
File: form.go
Package: ui

Signature

1func OnClick(btn *Clickable, w W, onclick func()) W

Description

OnClick wraps any widget with click handling functionality.
When the wrapped widget is clicked, the onclick callback is invoked.

Example:

btn := &Clickable{}
clickable := OnClick(btn, Label("Click me"), func() {
    fmt.Println("Widget was clicked!")
})

This allows any widget to become interactive without modifying its implementation.

Examples

OnClick

1{
2	btn := &Clickable{}
3	_ = OnClick(btn, Label("Click me"), func() {
4
5	})
6}

Example Output


This documentation is auto-generated. To update, run make docs

Backlinks