mouse.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package desktop
  2. import "fyne.io/fyne/v2"
  3. // MouseButton represents a single button in a desktop MouseEvent
  4. type MouseButton int
  5. const (
  6. // MouseButtonPrimary is the most common mouse button - on some systems the only one.
  7. // This will normally be on the left side of a mouse.
  8. //
  9. // Since: 2.0
  10. MouseButtonPrimary MouseButton = 1 << iota
  11. // MouseButtonSecondary is the secondary button on most mouse input devices.
  12. // This will normally be on the right side of a mouse.
  13. //
  14. // Since: 2.0
  15. MouseButtonSecondary
  16. // MouseButtonTertiary is the middle button on the mouse, assuming it has one.
  17. //
  18. // Since: 2.0
  19. MouseButtonTertiary
  20. // LeftMouseButton is the most common mouse button - on some systems the only one.
  21. //
  22. // Deprecated: use MouseButtonPrimary which will adapt to mouse configuration.
  23. LeftMouseButton = MouseButtonPrimary
  24. // RightMouseButton is the secondary button on most mouse input devices.
  25. //
  26. // Deprecated: use MouseButtonSecondary which will adapt to mouse configuration.
  27. RightMouseButton = MouseButtonSecondary
  28. )
  29. // MouseEvent contains data relating to desktop mouse events
  30. type MouseEvent struct {
  31. fyne.PointEvent
  32. Button MouseButton
  33. Modifier fyne.KeyModifier
  34. }
  35. // Mouseable represents desktop mouse events that can be sent to CanvasObjects
  36. type Mouseable interface {
  37. MouseDown(*MouseEvent)
  38. MouseUp(*MouseEvent)
  39. }
  40. // Hoverable is used when a canvas object wishes to know if a pointer device moves over it.
  41. type Hoverable interface {
  42. // MouseIn is a hook that is called if the mouse pointer enters the element.
  43. MouseIn(*MouseEvent)
  44. // MouseMoved is a hook that is called if the mouse pointer moved over the element.
  45. MouseMoved(*MouseEvent)
  46. // MouseOut is a hook that is called if the mouse pointer leaves the element.
  47. MouseOut()
  48. }