It is possible to return value from `connect_` closure?

Recently I wanted to remove .run() usage from my app, but I found that I can’t do this since I already take value from response and return it to other function.
My code before conversion looks that:

fn check_user_input() -> bool {
    let dialog = dialog::new();
    let response = dialog.run();
    if response == RESPONSE_OK{
        return true;
    }
    return false;
}

and I want to convert this to something like

fn check_user_input() -> bool {
    let dialog = dialog::new();
    dialog.connect_response(|dialog, response|{
    if response == RESPONSE_OK{
        return true; // This will fail because closure return ()(void, nothing)
    }
    return false;
    });
   // Compile error, function must return bool
}

Async/await must be used for this since the response signal is delivered asynchronously. It may be easier to use the run_future function as in the dialog example.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.