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

Method onCursorPos

gui/table.go:781–814  ·  view source on GitHub ↗

onCursorPos process subscribed cursor position events

(evname string, ev interface{})

Source from the content-addressed store, hash-verified

779
780// onCursorPos process subscribed cursor position events
781func (t *Table) onCursorPos(evname string, ev interface{}) {
782
783 // Convert mouse window coordinates to table content coordinates
784 cev := ev.(*window.CursorEvent)
785 cx, _ := t.ContentCoords(cev.Xpos, cev.Ypos)
786
787 // If user is dragging the resizer, updates its position
788 if t.resizing {
789 t.resizerPanel.SetPosition(cx, 0)
790 return
791 }
792
793 // Checks if the mouse cursor is near the border of a resizable column
794 found := false
795 for ci := 0; ci < len(t.header.cols); ci++ {
796 c := t.header.cols[ci]
797 dx := math32.Abs(cx - c.xr)
798 if dx < tableResizerPix {
799 if c.resize {
800 found = true
801 t.resizeCol = ci
802 t.resizerX = c.xr
803 window.Get().SetCursor(window.HResizeCursor)
804 }
805 break
806 }
807 }
808 // If column not found but previously was near a resizable column,
809 // resets the the window cursor.
810 if !found && t.resizeCol >= 0 {
811 window.Get().SetCursor(window.ArrowCursor)
812 t.resizeCol = -1
813 }
814}
815
816// onMouseEvent process subscribed mouse events
817func (t *Table) onMouse(evname string, ev interface{}) {

Callers

nothing calls this directly

Calls 5

AbsFunction · 0.92
GetFunction · 0.92
ContentCoordsMethod · 0.80
SetPositionMethod · 0.65
SetCursorMethod · 0.65

Tested by

no test coverage detected