Fix close button not working (#2533)

* Fix close button not working

By adding the close button after the title bar drag listener the close button will sense clicks.

* Update main.rs
This commit is contained in:
RadonCoding 2023-01-23 10:55:57 +02:00 committed by GitHub
parent 0ad8aea811
commit ce5472633d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,15 +84,6 @@ fn custom_window_frame(
Stroke::new(1.0, text_color), Stroke::new(1.0, text_color),
); );
// Add the close button:
let close_response = ui.put(
Rect::from_min_size(rect.left_top(), Vec2::splat(height)),
Button::new(RichText::new("").size(height - 4.0)).frame(false),
);
if close_response.clicked() {
frame.close();
}
// Interact with the title bar (drag to move window): // Interact with the title bar (drag to move window):
let title_bar_rect = { let title_bar_rect = {
let mut rect = rect; let mut rect = rect;
@ -105,6 +96,15 @@ fn custom_window_frame(
frame.drag_window(); frame.drag_window();
} }
// Add the close button:
let close_response = ui.put(
Rect::from_min_size(rect.left_top(), Vec2::splat(height)),
Button::new(RichText::new("").size(height - 4.0)).frame(false),
);
if close_response.clicked() {
frame.close();
}
// Add the contents: // Add the contents:
let content_rect = { let content_rect = {
let mut rect = rect; let mut rect = rect;