RibirX / Ribir

Non-intrusive GUI framework for Rust

Home Page:https://ribir.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support WindowEvent stream

M-Adoo opened this issue · comments

commented

Is your feature request related to a problem? Please describe.
User need to response to the window resize, close, etc. For example, when the window is closing, user need to release the resource, save the data, etc.

Describe the solution you'd like
A WindowEvent stream is needed. User can subscribe to the stream to get the event.

window.events().subscribe(|event| {
    match event {
        WindowEvent::Close => {
          // Cancel the window close.
          event.prevent_default();
        }
        WindowEvent::Resize => {
            // resize the window
        }
    }
});

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context

We introduced an AppEvent::WndFocusChanged(WindowId, bool) in #454 which should be removed in favor of this.