onCursorPos process subscribed cursor position events
(evname string, ev interface{})
| 779 | |
| 780 | // onCursorPos process subscribed cursor position events |
| 781 | func (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 |
| 817 | func (t *Table) onMouse(evname string, ev interface{}) { |
nothing calls this directly
no test coverage detected