@@ -173,25 +173,27 @@ use screencapturekit::prelude::*;
173173fn main () -> Result <(), Box <dyn std :: error :: Error >> {
174174 let config = SCContentSharingPickerConfiguration :: new ();
175175
176- // Advanced API: Get filter with metadata (dimensions, scale)
177- match SCContentSharingPicker :: pick (& config ) {
178- SCPickerOutcome :: Picked (result ) => {
179- // Get dimensions from the picked content
180- let (width , height ) = result . pixel_size ();
181- println! (" Selected: {}x{} (scale: {})" , width , height , result . scale ());
182-
183- let stream_config = SCStreamConfiguration :: new ()
184- . with_width (width )
185- . with_height (height );
186-
187- // Get filter for streaming
188- let filter = result . filter ();
189- let mut stream = SCStream :: new (& filter , & stream_config );
190- // ...
176+ // Show picker - callback receives result when user selects or cancels
177+ SCContentSharingPicker :: show (& config , | outcome | {
178+ match outcome {
179+ SCPickerOutcome :: Picked (result ) => {
180+ // Get dimensions from the picked content
181+ let (width , height ) = result . pixel_size ();
182+ println! (" Selected: {}x{} (scale: {})" , width , height , result . scale ());
183+
184+ let stream_config = SCStreamConfiguration :: new ()
185+ . with_width (width )
186+ . with_height (height );
187+
188+ // Get filter for streaming
189+ let filter = result . filter ();
190+ let mut stream = SCStream :: new (& filter , & stream_config );
191+ // ...
192+ }
193+ SCPickerOutcome :: Cancelled => println! (" User cancelled" ),
194+ SCPickerOutcome :: Error (e ) => eprintln! (" Error: {}" , e ),
191195 }
192- SCPickerOutcome :: Cancelled => println! (" User cancelled" ),
193- SCPickerOutcome :: Error (e ) => eprintln! (" Error: {}" , e ),
194- }
196+ });
195197
196198 Ok (())
197199}
@@ -211,7 +213,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
211213 let config = SCContentSharingPickerConfiguration :: new ();
212214
213215 // Async picker - doesn't block the executor
214- match AsyncSCContentSharingPicker :: pick (& config ). await {
216+ match AsyncSCContentSharingPicker :: show (& config ). await {
215217 SCPickerOutcome :: Picked (result ) => {
216218 let (width , height ) = result . pixel_size ();
217219 println! (" Selected: {}x{}" , width , height );
0 commit comments