onMouseEvent process subscribed mouse events
(evname string, ev interface{})
| 815 | |
| 816 | // onMouseEvent process subscribed mouse events |
| 817 | func (t *Table) onMouse(evname string, ev interface{}) { |
| 818 | |
| 819 | e := ev.(*window.MouseEvent) |
| 820 | Manager().SetKeyFocus(t) |
| 821 | switch evname { |
| 822 | case OnMouseDown: |
| 823 | // If over a resizable column border, shows the resizer panel |
| 824 | if t.resizeCol >= 0 && e.Button == window.MouseButtonLeft { |
| 825 | t.resizing = true |
| 826 | height := t.ContentHeight() |
| 827 | if t.statusPanel.Visible() { |
| 828 | height -= t.statusPanel.Height() |
| 829 | } |
| 830 | px := t.resizerX - t.resizerPanel.Width()/2 |
| 831 | t.resizerPanel.SetPositionX(px) |
| 832 | t.resizerPanel.SetHeight(height) |
| 833 | t.resizerPanel.SetVisible(true) |
| 834 | t.SetTopChild(&t.resizerPanel) |
| 835 | return |
| 836 | } |
| 837 | // Find click position |
| 838 | var tce TableClickEvent |
| 839 | tce.MouseEvent = *e |
| 840 | t.findClick(&tce) |
| 841 | // If row is clicked, selects it |
| 842 | if tce.Row >= 0 && e.Button == window.MouseButtonLeft { |
| 843 | t.rowCursor = tce.Row |
| 844 | if t.selType == TableSelMultiRow && e.Mods == window.ModControl { |
| 845 | t.toggleRowSel(t.rowCursor) |
| 846 | } |
| 847 | t.recalc() |
| 848 | t.Dispatch(OnChange, nil) |
| 849 | } |
| 850 | // Creates and dispatch TableClickEvent for user's context menu |
| 851 | t.Dispatch(OnTableClick, tce) |
| 852 | case OnMouseUp: |
| 853 | // If user was resizing a column, hides the resizer and |
| 854 | // sets the new column width if possible |
| 855 | if t.resizing { |
| 856 | t.resizing = false |
| 857 | t.resizerPanel.SetVisible(false) |
| 858 | window.Get().SetCursor(window.ArrowCursor) |
| 859 | // Calculates the new column width |
| 860 | cx, _ := t.ContentCoords(e.Xpos, e.Ypos) |
| 861 | c := t.header.cols[t.resizeCol] |
| 862 | width := cx - c.xl |
| 863 | t.setColWidth(c, width) |
| 864 | } |
| 865 | default: |
| 866 | return |
| 867 | } |
| 868 | } |
| 869 | |
| 870 | // onKeyEvent receives subscribed key events for this table |
| 871 | func (t *Table) onKey(evname string, ev interface{}) { |
nothing calls this directly
no test coverage detected