HoverGestures.swift 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. extension BackendFeatures {
  2. /// Backend methods for hover gesture handling.
  3. ///
  4. /// These are used by ``View/onHover(perform:)``.
  5. @MainActor
  6. public protocol HoverGestures: Core {
  7. /// Wraps a view in a container that can receive mouse hover events.
  8. ///
  9. /// Some backends may not have to wrap the child, in which case they may
  10. /// just return the child as-is.
  11. ///
  12. /// - Parameter child: The child to wrap.
  13. /// - Returns: A widget that can receive mouse hover events.
  14. func createHoverTarget(wrapping child: Widget) -> Widget
  15. /// Update the hover target with a new action.
  16. ///
  17. /// The new action replaces the old action.
  18. ///
  19. /// - Parameters:
  20. /// - hoverTarget: The hover target to update.
  21. /// - environment: The current environment.
  22. /// - action: The action to perform when the hover state changes. Receives
  23. /// a `Bool` indicating whether the hover has started or stopped.
  24. func updateHoverTarget(
  25. _ hoverTarget: Widget,
  26. environment: EnvironmentValues,
  27. action: @escaping (Bool) -> Void
  28. )
  29. }
  30. }