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

Method handleEvent

core/renderwindow.go:426–446  ·  view source on GitHub ↗

handleEvent processes given events.Event. All event processing operates under a RenderContext.Lock so that no rendering update can occur during event-driven updates. Because rendering itself is event driven, this extra level of safety is redundant in this case, but other non-event-driven updates req

(e events.Event)

Source from the content-addressed store, hash-verified

424// is redundant in this case, but other non-event-driven updates require
425// the lock protection.
426func (w *renderWindow) handleEvent(e events.Event) {
427 rc := w.renderContext()
428 rc.lock()
429 // we manually handle Unlock's in this function instead of deferring
430 // it to avoid a cryptic "sync: can't unlock an already unlocked Mutex"
431 // error when panicking in the rendering goroutine. This is critical for
432 // debugging on Android. TODO: maybe figure out a more sustainable approach to this.
433
434 et := e.Type()
435 if DebugSettings.EventTrace && et != events.WindowPaint && et != events.MouseMove {
436 fmt.Println("Window got event", e)
437 }
438 if et >= events.Window && et <= events.WindowPaint {
439 w.handleWindowEvents(e)
440 rc.unlock()
441 return
442 }
443 // fmt.Printf("got event type: %v: %v\n", et.BitIndexString(), evi)
444 w.mains.mainHandleEvent(e)
445 rc.unlock()
446}
447
448func (w *renderWindow) handleWindowEvents(e events.Event) {
449 et := e.Type()

Callers 1

eventLoopMethod · 0.95

Calls 7

renderContextMethod · 0.95
handleWindowEventsMethod · 0.95
lockMethod · 0.80
PrintlnMethod · 0.80
unlockMethod · 0.80
TypeMethod · 0.65
mainHandleEventMethod · 0.45

Tested by

no test coverage detected