Skip to content

Commit

Permalink
- implemnent window close functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
polymonster committed Jun 3, 2024
1 parent 44ea771 commit b7b7e3c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/os/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extern crate objc;
use std::time::Duration;

use winit::{
event::{Event, WindowEvent}, event_loop::ControlFlow, platform::pump_events::EventLoopExtPumpEvents, raw_window_handle::{HasWindowHandle, RawWindowHandle}
event::{Event, WindowEvent}, event_loop::ControlFlow, platform::pump_events::{EventLoopExtPumpEvents, PumpStatus}, raw_window_handle::{HasWindowHandle, RawWindowHandle}
};

use cocoa::{appkit::NSView, base::id as cocoa_id};
Expand Down Expand Up @@ -58,10 +58,25 @@ impl super::App for App {

/// Call to update windows and os state each frame, when false is returned the app has been requested to close
fn run(&mut self) -> bool {
let mut resume = true;
let status = self.event_loop.pump_events(Some(Duration::ZERO), |event, elwt| {
match event {
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => {
resume = false;
}
_ => {

}
}
_ => {

}
}

println!("{}", "inside");
});
true
resume
}

/// Request to exit the application
Expand Down

0 comments on commit b7b7e3c

Please sign in to comment.