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

Method onCursor

gui/window.go:382–400  ·  view source on GitHub ↗

onCursor process subscribed cursor events over the window title.

(evname string, ev interface{})

Source from the content-addressed store, hash-verified

380
381// onCursor process subscribed cursor events over the window title.
382func (wt *WindowTitle) onCursor(evname string, ev interface{}) {
383
384 if evname == OnCursorLeave {
385 window.Get().SetCursor(window.ArrowCursor)
386 wt.pressed = false
387 } else if evname == OnCursor {
388 if !wt.pressed {
389 return
390 }
391 cev := ev.(*window.CursorEvent)
392 dy := wt.mouseY - cev.Ypos
393 dx := wt.mouseX - cev.Xpos
394 wt.mouseX = cev.Xpos
395 wt.mouseY = cev.Ypos
396 posX := wt.win.Position().X - dx
397 posY := wt.win.Position().Y - dy
398 wt.win.SetPosition(posX, posY)
399 }
400}
401
402// applyStyle applies the specified WindowTitleStyle.
403func (wt *WindowTitle) applyStyle(s *WindowTitleStyle) {

Callers

nothing calls this directly

Calls 4

GetFunction · 0.92
SetCursorMethod · 0.65
PositionMethod · 0.65
SetPositionMethod · 0.65

Tested by

no test coverage detected