MCPcopy Create free account
hub / github.com/cogentcore/core / Button

Struct Button

core/button.go:28–61  ·  view source on GitHub ↗

Button is an interactive button with text, an icon, an indicator, a shortcut, and/or a menu. The standard behavior is to register a click event handler with [WidgetBase.OnClick].

Source from the content-addressed store, hash-verified

26// and/or a menu. The standard behavior is to register a click event handler with
27// [WidgetBase.OnClick].
28type Button struct { //core:embedder
29 Frame
30
31 // Type is the type of button.
32 Type ButtonTypes
33
34 // Text is the text for the button.
35 // If it is blank, no text is shown.
36 Text string
37
38 // Icon is the icon for the button.
39 // If it is "" or [icons.None], no icon is shown.
40 Icon icons.Icon
41
42 // Indicator is the menu indicator icon to present.
43 // If it is "" or [icons.None],, no indicator is shown.
44 // It is automatically set to [icons.KeyboardArrowDown]
45 // when there is a Menu elements present unless it is
46 // set to [icons.None].
47 Indicator icons.Icon
48
49 // Shortcut is an optional shortcut keyboard chord to trigger this button,
50 // active in window-wide scope. Avoid conflicts with other shortcuts
51 // (a log message will be emitted if so). Shortcuts are processed after
52 // all other processing of keyboard input. Command is automatically translated
53 // into Meta on macOS and Control on all other platforms. Also see [Button.SetKey].
54 Shortcut key.Chord
55
56 // Menu is a menu constructor function used to build and display
57 // a menu whenever the button is clicked. There will be no menu
58 // if it is nil. The constructor function should add buttons
59 // to the Scene that it is passed.
60 Menu func(m *Scene) `json:"-" xml:"-"`
61}
62
63// ButtonTypes is an enum containing the
64// different possible types of buttons.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected