Expand description
SCContentSharingPicker - UI for selecting content to share
Available on macOS 14.0+. Provides a system UI for users to select displays, windows, or applications to share.
§When to Use
Use the content sharing picker when:
- You want users to choose what to capture via a native macOS UI
- You need consistent UX with other screen sharing apps
- You want to avoid manually listing and presenting content options
§APIs
| Method | Returns | Use Case |
|---|---|---|
SCContentSharingPicker::show() | callback with SCPickerOutcome | Get filter + metadata (dimensions, picked content) |
SCContentSharingPicker::show_filter() | callback with SCPickerFilterOutcome | Just get the filter |
For async/await, use AsyncSCContentSharingPicker from the async_api module.
§Examples
§Callback API: Get filter with metadata
use screencapturekit::content_sharing_picker::*;
use screencapturekit::prelude::*;
let config = SCContentSharingPickerConfiguration::new();
SCContentSharingPicker::show(&config, |outcome| {
match outcome {
SCPickerOutcome::Picked(result) => {
let (width, height) = result.pixel_size();
let filter = result.filter();
println!("Selected content: {}x{}", width, height);
// Create stream with the filter...
}
SCPickerOutcome::Cancelled => println!("Cancelled"),
SCPickerOutcome::Error(e) => eprintln!("Error: {}", e),
}
});§Async API
use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;
async fn example() {
let config = SCContentSharingPickerConfiguration::new();
if let SCPickerOutcome::Picked(result) = AsyncSCContentSharingPicker::show(&config).await {
let (width, height) = result.pixel_size();
let filter = result.filter();
println!("Selected: {}x{}", width, height);
}
}§Configure Picker Modes
use screencapturekit::content_sharing_picker::*;
let mut config = SCContentSharingPickerConfiguration::new();
// Only allow single display selection
config.set_allowed_picker_modes(&[SCContentSharingPickerMode::SingleDisplay]);
// Exclude specific apps from the picker
config.set_excluded_bundle_ids(&["com.apple.finder", "com.apple.dock"]);Structs§
- SCContent
Sharing Picker - System UI for selecting content to share
- SCContent
Sharing Picker Configuration - Configuration for the content sharing picker
- SCPicker
Result - Result from the main
show()API - contains filter and content metadata
Enums§
- SCContent
Sharing Picker Mode - Picker mode determines what content types can be selected
- SCPicked
Source - Represents the type of content selected in the picker
- SCPicker
Filter Outcome - Result from the simple
show_filter()API - SCPicker
Outcome - Outcome from the main
show()API