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

Method handleWidgetStateFromMouse

core/widgetevents.go:314–375  ·  view source on GitHub ↗

handleWidgetStateFromMouse updates all standard State flags based on mouse events, such as MouseDown / Up -> Active and MouseEnter / Leave -> Hovered. None of these "consume" the event by setting Handled flag, as they are designed to work in conjunction with more specific handlers. Note that Disable

()

Source from the content-addressed store, hash-verified

312// Note that Disabled and Invisible widgets do NOT receive
313// these events so it is not necessary to check that.
314func (wb *WidgetBase) handleWidgetStateFromMouse() {
315 wb.On(events.MouseDown, func(e events.Event) {
316 if wb.AbilityIs(abilities.Activatable) {
317 wb.SetState(true, states.Active)
318 }
319 })
320 wb.On(events.MouseUp, func(e events.Event) {
321 if wb.AbilityIs(abilities.Activatable) {
322 wb.SetState(false, states.Active)
323 }
324 })
325 wb.On(events.LongPressStart, func(e events.Event) {
326 if wb.AbilityIs(abilities.LongPressable) {
327 wb.SetState(true, states.LongPressed)
328 }
329 })
330 wb.On(events.LongPressEnd, func(e events.Event) {
331 if wb.AbilityIs(abilities.LongPressable) {
332 wb.SetState(false, states.LongPressed)
333 }
334 })
335 wb.On(events.MouseEnter, func(e events.Event) {
336 if wb.AbilityIs(abilities.Hoverable) {
337 wb.SetState(true, states.Hovered)
338 }
339 })
340 wb.On(events.MouseLeave, func(e events.Event) {
341 if wb.AbilityIs(abilities.Hoverable) {
342 wb.SetState(false, states.Hovered)
343 }
344 })
345 wb.On(events.LongHoverStart, func(e events.Event) {
346 if wb.AbilityIs(abilities.LongHoverable) {
347 wb.SetState(true, states.LongHovered)
348 }
349 })
350 wb.On(events.LongHoverEnd, func(e events.Event) {
351 if wb.AbilityIs(abilities.LongHoverable) {
352 wb.SetState(false, states.LongHovered)
353 }
354 })
355 wb.On(events.SlideStart, func(e events.Event) {
356 if wb.AbilityIs(abilities.Slideable) {
357 wb.SetState(true, states.Sliding)
358 }
359 })
360 wb.On(events.SlideStop, func(e events.Event) {
361 if wb.AbilityIs(abilities.Slideable) {
362 wb.SetState(false, states.Sliding, states.Active)
363 }
364 })
365 wb.On(events.DragStart, func(e events.Event) {
366 if wb.AbilityIs(abilities.Draggable) {
367 wb.SetState(true, states.Dragging)
368 }
369 })
370 wb.On(events.Drop, func(e events.Event) {
371 if wb.AbilityIs(abilities.Draggable) {

Callers 1

InitMethod · 0.95

Calls 3

OnMethod · 0.95
AbilityIsMethod · 0.95
SetStateMethod · 0.95

Tested by

no test coverage detected