findClick finds where in the table the specified mouse click event occurred updating the specified TableClickEvent with the click coordinates.
(ev *TableClickEvent)
| 936 | // findClick finds where in the table the specified mouse click event |
| 937 | // occurred updating the specified TableClickEvent with the click coordinates. |
| 938 | func (t *Table) findClick(ev *TableClickEvent) { |
| 939 | |
| 940 | x, y := t.ContentCoords(ev.Xpos, ev.Ypos) |
| 941 | ev.X = x |
| 942 | ev.Y = y |
| 943 | ev.Row = -1 |
| 944 | // Find column id |
| 945 | colx := float32(0) |
| 946 | for ci := 0; ci < len(t.header.cols); ci++ { |
| 947 | c := t.header.cols[ci] |
| 948 | if !c.Visible() { |
| 949 | continue |
| 950 | } |
| 951 | colx += t.header.cols[ci].Width() |
| 952 | if x < colx { |
| 953 | ev.Col = c.id |
| 954 | ev.ColOrder = ci |
| 955 | break |
| 956 | } |
| 957 | } |
| 958 | // If column not found the user clicked at the right of rows |
| 959 | if ev.Col == "" { |
| 960 | return |
| 961 | } |
| 962 | // Checks if is in header |
| 963 | if t.header.Visible() && y < t.header.Height() { |
| 964 | ev.Header = true |
| 965 | } |
| 966 | |
| 967 | // Find row clicked |
| 968 | rowy := float32(0) |
| 969 | if t.header.Visible() { |
| 970 | rowy = t.header.Height() |
| 971 | } |
| 972 | theight := t.ContentHeight() |
| 973 | for ri := t.firstRow; ri < len(t.rows); ri++ { |
| 974 | trow := t.rows[ri] |
| 975 | rowy += trow.height |
| 976 | if rowy > theight { |
| 977 | break |
| 978 | } |
| 979 | if y < rowy { |
| 980 | ev.Row = ri |
| 981 | break |
| 982 | } |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | // selNext selects the next row if possible |
| 987 | func (t *Table) selNext() { |
no test coverage detected