WindowModifiers.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. extension View {
  2. /// Sets the closability of the enclosing window.
  3. ///
  4. /// This only controls whether user can close the window via the title
  5. /// bar close button, built-in keyboard shortcuts such as Cmd+W or Alt+F4,
  6. /// etc. Windows can always be closed programmatically.
  7. public func windowDismissBehavior(_ behavior: WindowInteractionBehavior) -> some View {
  8. preference(key: \.windowDismissBehavior, value: behavior)
  9. }
  10. /// Sets the minimizability of the enclosing window.
  11. ///
  12. /// - Important: This isn't supported on GtkBackend or Gtk3Backend, both of
  13. /// which ignore the corresponding preference value.
  14. public func preferredWindowMinimizeBehavior(
  15. _ behavior: WindowInteractionBehavior
  16. ) -> some View {
  17. preference(key: \.preferredWindowMinimizeBehavior, value: behavior)
  18. }
  19. /// Sets the resizability of the enclosing window.
  20. ///
  21. /// This modifier controls whether the user can resize the enclosing window,
  22. /// whereas ``Scene/windowResizability(_:)`` controls how SwiftCrossUI
  23. /// determines the bounds within which windows can be resized. The only time
  24. /// that ``Scene/windowResizability(_:)`` can disable interactive resizing
  25. /// is when the window's content has a fixed size and the
  26. /// ``WindowResizability`` is ``WindowResizability/contentSize``.
  27. public func windowResizeBehavior(_ behavior: WindowInteractionBehavior) -> some View {
  28. preference(key: \.windowResizeBehavior, value: behavior)
  29. }
  30. }