MCPcopy Index your code
hub / github.com/g3n/engine / onMouse

Method onMouse

gui/manager.go:115–143  ·  view source on GitHub ↗

onMouse is called when mouse events are received. OnMouseDown/OnMouseUp are dispatched to gm.target or to non-GUI, while OnMouseDownOut/OnMouseUpOut are dispatched to all non-target panels.

(evname string, ev interface{})

Source from the content-addressed store, hash-verified

113// OnMouseDown/OnMouseUp are dispatched to gm.target or to non-GUI, while
114// OnMouseDownOut/OnMouseUpOut are dispatched to all non-target panels.
115func (gm *manager) onMouse(evname string, ev interface{}) {
116
117 // Check if gm.scene is nil and if so then there are no IPanels to send events to
118 if gm.scene == nil {
119 gm.Dispatch(evname, ev) // Dispatch event to non-GUI since event was not filtered by any GUI component
120 return
121 }
122
123 // Dispatch OnMouseDownOut/OnMouseUpOut to all panels except ancestors of target
124 gm.forEachIPanel(func(ipan IPanel) {
125 if gm.target == nil || !ipan.IsAncestorOf(gm.target) {
126 switch evname {
127 case OnMouseDown:
128 ipan.Dispatch(OnMouseDownOut, ev)
129 case OnMouseUp:
130 ipan.Dispatch(OnMouseUpOut, ev)
131 }
132 }
133 })
134
135 // Appropriately dispatch the event to target panel's lowest subscribed ancestor or to non-GUI or not at all
136 if gm.target != nil {
137 if gm.modal == nil || gm.modal.IsAncestorOf(gm.target) {
138 sendAncestry(gm.target, false, nil, gm.modal, evname, ev)
139 }
140 } else if gm.modal == nil {
141 gm.Dispatch(evname, ev)
142 }
143}
144
145// onScroll is called when scroll events are received.
146// The events are dispatched to the target panel or to non-GUI.

Callers

nothing calls this directly

Calls 4

forEachIPanelMethod · 0.95
sendAncestryFunction · 0.85
DispatchMethod · 0.65
IsAncestorOfMethod · 0.65

Tested by

no test coverage detected