onCursor receives subscribed cursor events for the scroll bar button
(evname string, ev interface{})
| 223 | |
| 224 | // onCursor receives subscribed cursor events for the scroll bar button |
| 225 | func (button *scrollBarButton) onCursor(evname string, ev interface{}) { |
| 226 | |
| 227 | e := ev.(*window.CursorEvent) |
| 228 | if !button.pressed { |
| 229 | return |
| 230 | } |
| 231 | if button.sb.vertical { |
| 232 | dy := button.mouseY - e.Ypos |
| 233 | py := button.Position().Y |
| 234 | button.SetPositionY(math32.Clamp(py-dy, 0, button.sb.content.Height-button.Size)) |
| 235 | } else { |
| 236 | dx := button.mouseX - e.Xpos |
| 237 | px := button.Position().X |
| 238 | button.SetPositionX(math32.Clamp(px-dx, 0, button.sb.content.Width-button.Size)) |
| 239 | } |
| 240 | button.mouseX = e.Xpos |
| 241 | button.mouseY = e.Ypos |
| 242 | button.sb.Dispatch(OnChange, nil) |
| 243 | } |
nothing calls this directly
no test coverage detected