Help understanding/utilizing window::Action

Programming isn’t my primary job role at work, but I use Rust for building small applications for work. Every time I get back into programming with Iced, new cool changes have been implemented. So, I am constantly learning.
I’m trying to build a MouseArea interaction to eventually develop a functionality for a Drag & Drop from one application to another. I created a container with a Text label and TextInput. Then, wrapped into a MouseArea for the mouse interaction. The .on_relase() is transmitting the Message correctly for a println!(). I wanted to try interactions for the active Iced window. Simply, trying to resize the window with MouseArea.on_release(). I don’t think I am understanding the window::Action. I can see the println!() message, but there is no window action. I would appreciate help explaining what I am missing:

struct AppState {
    trigger: String,
    bin_word: Option<BinWord>,
    window_id: Id,
    clipboard: Clipboard,
}

impl Default for AppState {
    fn default() -> Self {
        AppState {
            bin_word: None,
            trigger: String::default(),
            window_id: Id::unique(),
            clipboard: Clipboard::unconnected(),
        }
    }
}

#[derive(Debug, Clone)]
enum Message {
    TriggerChanged(String),
    TriggerSubmitted(String),
    TriggerDropped,
}

fn update(app_state: &mut AppState,  message: Message) {
    match message {
        Message::TriggerChanged(value) => {app_state.trigger = String::from(value.trim())},
        TriggerSubmitted(mut value) => {
            value = value.trim().to_string();
            let trigger = value.parse::<u32>().unwrap_or_else(|_| 4294967295u32);
            app_state.bin_word =  Some(BinWord::trigger_to_word(trigger));
            app_state.trigger = String::from(value);
        },
        TriggerDropped => {
            println!("WindowId = {}",  app_state.window_id);
            Action::ToggleMaximize(app_state.window_id);
        }
    }
}

fn view(app_state: &AppState) -> Element<Message> {
    
    //let mut trigger_row: Row<Message> = Row::new();
    let trigger_textinput = TextInput::new("4294967295", &app_state.trigger.to_string())
        .on_input(Message::TriggerChanged)
        .on_submit(TriggerSubmitted(String::from(&app_state.trigger)))
        .on_paste(TriggerSubmitted)
        .width(Length::Fixed(150.0));

    let trigger_row = row!["Trigger: ",trigger_textinput]
        .spacing(10);

    let trigger_container =  Container::new(trigger_row)
        .padding(10.0);

    let text_input_area = MouseArea::new(trigger_container)
        .on_release(TriggerDropped);

    match &app_state.bin_word {
        None => {         
            column![
                Space::with_height(Length::Fixed(10.0)),
                text_input_area,
            ]
                .padding(10.0)
                .into()
                
        }
        Some(bin_word) => {
            //let bin_word_row: Row<Message> = Row::new();
            column![
                Space::with_height(Length::Fixed(10.0)),
                text_input_area,
                Space::with_height(Length::Fixed(10.0)),
                binword_display(bin_word),
            ]
                .into()
        }
    }
}

TogleMaximize returns a Task, and you need to return this Task in your update method.

Ah, ok, I was using the window::Action enum…I updated the Update and it’s still not maximizing:

fn update(app_state: &mut AppState,  message: Message) -> impl Into<Task<Message>>{
    match message {
        Message::TriggerChanged(value) => {
            app_state.trigger = String::from(value.trim());
            Task::none()
        },
        TriggerSubmitted(mut value) => {
            value = value.trim().to_string();
            let trigger = value.parse::<u32>().unwrap_or_else(|_| 4294967295u32);
            app_state.bin_word =  Some(BinWord::trigger_to_word(trigger));
            app_state.trigger = String::from(value);
            Task::none()
        },
        TriggerDropped => {
            println!("WindowId = {}",  app_state.window_id);
            window::toggle_maximize(app_state.window_id)
        }
    }
}

If I understand correctly you never query the actual id of the window, you just set it to Id::unique() in the default state. You need to query the id, and there are a couple of actions in the window module to do so, like get_latest and get_oldest. Keep in mind that those methods also return Tasks, but you can combine both tasks (get the id and maximize the window) into one by using the methods available in Task, like and_then and others of the sort.

Thanks! Here’s where I am with this. I think I am hung up executing the Task. I tried window::get_latest() and chaining it with Task::and_then(). Now, I cannot see the println!():

fn update(app_state: &mut AppState,  message: Message) {
    match message {
        Message::TriggerChanged(value) => {
            app_state.trigger = String::from(value.trim());
            //Task::none()
        },
        TriggerSubmitted(mut value) => {
            value = value.trim().to_string();
            let trigger = value.parse::<u32>().unwrap_or_else(|_| 4294967295u32);
            app_state.bin_word =  Some(BinWord::trigger_to_word(trigger));
            app_state.trigger = String::from(value);
            //Task::none()
        },
        TriggerDropped => {
            let _ = get_latest().and_then(|id| {
                println!("WindowID = {}", id);
                maximize::<AppState>(id, true)
            });
                
        }
    }
}

Is it because get_latest() is not executing the Task?

Replace that let _ = with a return; Tasks are only executed when you return them to the runtime. You may also have to .map the resulting Task to a Message, or .discard it.