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

Method handleWidgetClick

core/widgetevents.go:290–305  ·  view source on GitHub ↗

handleWidgetClick handles the Click event for basic Widget behavior. For Left button: If Checkable, toggles Checked. if Focusable, Focuses or clears, If Selectable, updates state and sends Select, Deselect.

()

Source from the content-addressed store, hash-verified

288// If Checkable, toggles Checked. if Focusable, Focuses or clears,
289// If Selectable, updates state and sends Select, Deselect.
290func (wb *WidgetBase) handleWidgetClick() {
291 wb.OnClick(func(e events.Event) {
292 if wb.AbilityIs(abilities.Checkable) {
293 wb.SetState(!wb.StateIs(states.Checked), states.Checked)
294 }
295 if wb.AbilityIs(abilities.Focusable) {
296 wb.SetFocus()
297 } else {
298 wb.focusClear()
299 }
300 // note: read only widgets are automatically selectable
301 if wb.AbilityIs(abilities.Selectable) || wb.IsReadOnly() {
302 wb.Send(events.Select, e)
303 }
304 })
305}
306
307// handleWidgetStateFromMouse updates all standard
308// State flags based on mouse events,

Callers 1

InitMethod · 0.95

Calls 8

OnClickMethod · 0.95
AbilityIsMethod · 0.95
SetStateMethod · 0.95
StateIsMethod · 0.95
SetFocusMethod · 0.95
focusClearMethod · 0.95
IsReadOnlyMethod · 0.95
SendMethod · 0.95

Tested by

no test coverage detected