copybutton

package
v1.0.31-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package copybutton provides a button that copies text to the clipboard and briefly confirms it with a check mark.

Index

Constants

View Source
const DefaultFeedback = 1500 * time.Millisecond

DefaultFeedback is how long the check mark shows after copying.

Variables

This section is empty.

Functions

This section is empty.

Types

type CopyButton

type CopyButton struct {
	// Contextual gives it a context menu (Context).
	elements.Contextual
	// contains filtered or unexported fields
}

CopyButton copies text to the clipboard when clicked and shows a check mark (and its "copied" label) for a moment. Create it once and lay it out every frame:

copy := giode.CopyButton(func() string { return apiKey.Text() })

func New

func New(text func() string, st ...styles.Styles) *CopyButton

New returns a button copying text() when clicked. The styles argument is optional: Color (glyph and label, default theme.text), Background, Padding, BorderRadius, FontSize.

func (*CopyButton) Click

func (c *CopyButton) Click()

Click copies as a click would; call it on the UI goroutine.

func (*CopyButton) Copied

func (c *CopyButton) Copied() bool

Copied reports whether the confirmation is showing.

func (*CopyButton) Feedback

func (c *CopyButton) Feedback(d time.Duration) *CopyButton

Feedback sets how long the check mark shows. It returns c for chaining.

func (*CopyButton) Labels

func (c *CopyButton) Labels(label, copied string) *CopyButton

Labels sets the text shown before and after copying; empty strings show the glyph alone. It returns c for chaining.

func (*CopyButton) Layout

func (c *CopyButton) Layout(gtx layout.Context) layout.Dimensions

Layout lays out and updates the button.

func (*CopyButton) OnCopy

func (c *CopyButton) OnCopy(fn func(text string)) *CopyButton

OnCopy sets a handler run with the copied text. It returns c for chaining.

Jump to

Keyboard shortcuts

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