Documentation
¶
Overview ¶
Package copybutton provides a button that copies text to the clipboard and briefly confirms it with a check mark.
Index ¶
- Constants
- type CopyButton
- func (c *CopyButton) Click()
- func (c *CopyButton) Copied() bool
- func (c *CopyButton) Feedback(d time.Duration) *CopyButton
- func (c *CopyButton) Labels(label, copied string) *CopyButton
- func (c *CopyButton) Layout(gtx layout.Context) layout.Dimensions
- func (c *CopyButton) OnCopy(fn func(text string)) *CopyButton
Constants ¶
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.