MCPcopy
hub / github.com/g3n/engine / onCursor

Method onCursor

gui/scrollbar.go:225–243  ·  view source on GitHub ↗

onCursor receives subscribed cursor events for the scroll bar button

(evname string, ev interface{})

Source from the content-addressed store, hash-verified

223
224// onCursor receives subscribed cursor events for the scroll bar button
225func (button *scrollBarButton) onCursor(evname string, ev interface{}) {
226
227 e := ev.(*window.CursorEvent)
228 if !button.pressed {
229 return
230 }
231 if button.sb.vertical {
232 dy := button.mouseY - e.Ypos
233 py := button.Position().Y
234 button.SetPositionY(math32.Clamp(py-dy, 0, button.sb.content.Height-button.Size))
235 } else {
236 dx := button.mouseX - e.Xpos
237 px := button.Position().X
238 button.SetPositionX(math32.Clamp(px-dx, 0, button.sb.content.Width-button.Size))
239 }
240 button.mouseX = e.Xpos
241 button.mouseY = e.Ypos
242 button.sb.Dispatch(OnChange, nil)
243}

Callers

nothing calls this directly

Calls 5

ClampFunction · 0.92
PositionMethod · 0.65
SetPositionYMethod · 0.65
SetPositionXMethod · 0.65
DispatchMethod · 0.65

Tested by

no test coverage detected