JFLib

plat/apple_mac_share.rs (Apple)#

Source: lib/plat/apple_mac_share.rs

apple_mac_share -- (share.rs) macOS's share sheet: NSSharingServicePicker at the anchor in the key
window (the main window when none is key)

  share(&Share) -> SHARE_PENDING / SHARE_NONE   the picker shown relative to the anchor (points =
                               px over the window's backingScaleFactor; our views are flipped, so
                               y counts from the top), without one in the content view's middle
  available() -> bool          true (AppKit has the picker since 10.8)
  mac_share_shown() / mac_share_close()   (tests) the picker's window on screen, closed again

Items: the text (NSString), the link (NSURL), the files (file URLs).  The picker's delegate answers:
a service chosen -> SHARE_DONE (the service gets the title as its subject, Mail's subject line);
none (the picker closed) -> SHARE_CANCELLED.  Whether the service then delivers is its own
business (Android's chooser says as little).
  • fn mac_share_shown() -> bool (tests) the picker waits for the user (its answer not given yet)

  • fn mac_share_close() -> bool (tests, any thread) the open picker closed without a service, as the user's click outside it would (NSSharingServicePicker close, macOS 13; before that the delegate's answer is sent directly)

Source: docs/API.md in the JFLib repository.