Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Cancel native app close #391

Open
wana211 opened this issue Dec 16, 2022 · 4 comments
Open

Cancel native app close #391

wana211 opened this issue Dec 16, 2022 · 4 comments

Comments

@wana211
Copy link

wana211 commented Dec 16, 2022

Is it possible to cancel the native app being closed?
I can see a "HostClose" event on IChromelyNativeHost but this doesn't let you cancel. Perhaps "CloseEventArgs" could have a cancel property?

I'm developing a Cross-Platform app and when the native form is closed I need to cancel and show a "Are you sure message?" in case they have outstanding changes to save.

I have tried the Frameless option but this appears to only be implemented on Windows?

@mattkol
Copy link
Member

mattkol commented Dec 27, 2022

@DSEWayne I could not really find time to verify why 'HostClose" may not work because of the holidays. Are you able to verify that your code is being called?

@wana211
Copy link
Author

wana211 commented Dec 30, 2022

Hi, "HostClose" is being called and I can put code in there that is called upon close. I just can't see any way to cancel the close request. When the user closes the native app I want to be able to cancel the users close request if they have outstanding changes and prompt them with a HTML message box asking if they want to save before I allow the native app to be closed.

@mattkol
Copy link
Member

mattkol commented Jan 4, 2023

@DSEWayne I think I get your point now. There was never really any consideration for the option to avoid closing. The method was meant primarily to allow cleanups and other utility work before closing. What you are trying to do can be done though with some customization at your end.

@wana211
Copy link
Author

wana211 commented Jan 4, 2023

Thanks, I thought that was the case. By "customization at your end" do you mean modifying the Chromely source code? Or can it be done another way?
I have a local copy of the source code and I've added a Boolean "cancel" property to the event args passed into the "HostClose" event and this is working. I can create a fork and add my changes in there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants