Skip to content

Commit be0a02c

Browse files
committed
Handle window closed event
1 parent 648d18c commit be0a02c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backends/fltk.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ pub fn run_fltk_backend(main: fn() -> u16, receiver: Receiver<DialogMessageReque
5757

5858
fn create_messagebox(id: usize, data: MessageBoxData) -> DoubleWindow {
5959
let mut wind = Window::new(0, 0, 400, 300, data.title.as_str()).center_screen();
60+
61+
wind.set_callback(move |wnd| {
62+
wnd.hide();
63+
insert_result(id, MessageBoxResult::WindowClosed);
64+
});
65+
6066
wind.set_color(Color::White);
6167

6268
// Start Root column
@@ -173,8 +179,8 @@ fn create_messagebox(id: usize, data: MessageBoxData) -> DoubleWindow {
173179
wind.end();
174180

175181
// Before showing the window, try and compute the optimal window size.
176-
let xpad = if has_icon { 70 } else { 20 };
177-
let wind_size = calculate_ideal_window_size(data.message.as_str(), xpad, 100);
182+
let pad_x = if has_icon { 70 } else { 20 };
183+
let wind_size = calculate_ideal_window_size(data.message.as_str(), pad_x, 100);
178184
wind.set_size(wind_size.0, wind_size.1);
179185
let mut wind = wind.center_screen();
180186
flex_root_col.size_of_parent();

0 commit comments

Comments
 (0)