select/
select.rs

1use std::time::Duration;
2
3use win32_notif::{NotificationActivatedEventHandler, NotificationBuilder, ToastsNotifier, notification::{actions::{ActionButton, Input, action::ActivationType, input::Selection}, visual::Text}};
4// Input Selection Example
5
6
7fn main() {
8  let notifier = ToastsNotifier::new("Microsoft.Windows.Explorer").unwrap();
9
10  let notification = NotificationBuilder::new()
11    .visual(
12      Text::create(0, "Enter your name")
13    )
14    .action(
15      Input::create_selection_input(
16        "0", 
17        "Name", 
18        "AHQ",
19      vec![
20          Selection::new("1", "AHQ Novel"),
21          Selection::new("2", "AHQ Soft"),
22          Selection::new("3", "Wings of Fire")
23        ]
24      )
25    )
26    .action(
27      ActionButton::create("Submit")
28        .with_input_id("0")
29        // Required or else it would go to file explorer
30        .with_activation_type(ActivationType::Foreground)
31    )
32    .on_activated(NotificationActivatedEventHandler::new(|_notif, data| {
33      let data = data.unwrap();
34
35      println!("{:#?}", data);
36
37      Ok(())
38    }))
39    // Notification will be gone after 5 secs
40    .with_expiry(Duration::from_secs(5))
41    // sequence: a custom defined id (never used)
42    // tag, group: Unique notification identifier
43    // Notifier, ofc you its the notifier
44    .build(0, &notifier, "01", "input")
45    .unwrap();
46
47  notification.show()
48    .unwrap();
49
50  // App should be running
51  loop {
52    std::thread::sleep(Duration::from_secs(2));
53  }
54}