Skip to content

Commit

Permalink
Attempt to fix issue with modal windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtzxporter committed Feb 8, 2024
1 parent e91b08a commit ef6909e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/backend/macos/file_dialog/panel_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Panel {

pub fn run_modal(&self) -> i32 {
if let Some(parent) = self.parent.clone() {
let completion = { block::ConcreteBlock::new(|_: u32| {}) };
let completion = { block::ConcreteBlock::new(|_: isize| {}) };

unsafe {
msg_send![self.panel, beginSheetModalForWindow: parent completionHandler: &completion]
Expand Down
10 changes: 8 additions & 2 deletions src/backend/macos/message_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::{
AsModal,
};

use super::utils::{INSWindow, NSWindow};
use super::utils::{INSApplication, INSWindow, NSApplication, NSWindow};
use objc::runtime::Object;
use objc::{class, msg_send, sel, sel_impl};
use objc_foundation::{INSString, NSString};
Expand Down Expand Up @@ -104,7 +104,13 @@ impl NSAlert {

pub fn run(mut self) -> MessageDialogResult {
if let Some(parent) = self.parent.take() {
let completion = { block::ConcreteBlock::new(|_: u32| {}) };
let completion = {
block::ConcreteBlock::new(|result: isize| {
let _: () = unsafe {
msg_send![NSApplication::shared_application(), stopModalWithCode: result]
};
})
};

unsafe {
msg_send![self.alert, beginSheetModalForWindow: parent completionHandler: &completion]
Expand Down

0 comments on commit ef6909e

Please sign in to comment.