Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to intercept / veto window close #467

Closed
seanpringle opened this issue Sep 27, 2019 · 5 comments
Closed

Add ability to intercept / veto window close #467

seanpringle opened this issue Sep 27, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@seanpringle
Copy link

Is there a way to turn off the "Quit" option added to the gl driver's first main-menu menu?

if menu.Items[len(menu.Items)-1].Label != "Quit" { // make sure the first menu always has a quit option

Alternatively, a way to:

  • change the label to allow for language localisation
  • specify a custom action function (confirmation, unsaved work dialog, etc)
@andydotxyz
Copy link
Member

This is a slightly complicated area because macOS, other desktop and mobile devices all handle it differently.

Yes we should support localisation, that needs to be done correctly for the whole framework, however.

There is currently an OnClosed handler on Window that may help - but it seems like what you want is something to fire before closing that determines whether or not it should be allowed? (Is they correct?)

I suspect that configuring the quit menu is not the right approach because the window could be manually closed as well and that should probably trigger the same event..?

@seanpringle
Copy link
Author

There is currently an OnClosed handler on Window that may help - but it seems like what you want is something to fire before closing that determines whether or not it should be allowed? (Is they correct?)

Correct.

I suspect that configuring the quit menu is not the right approach because the window could be manually closed as well and that should probably trigger the same event..?

That sounds logical. Maybe even a general purpose interface for hooking onto window management events?

@andydotxyz
Copy link
Member

I don’t know if we can really extend it that far as the events vary significantly across platforms. We can certainly add an abstraction where such support makes sense. Starting with WillClose to complement OnClose perhaps? (Unless anyone suggests a better name)

@seanpringle
Copy link
Author

WillClose sounds great.

@andydotxyz andydotxyz changed the title control over the Quit option added to gl driver main menu Add ability to intercept / veto window close Sep 30, 2019
@andydotxyz andydotxyz added the enhancement New feature or request label Sep 30, 2019
@andydotxyz andydotxyz added this to the 1.2 - Mobile support milestone Sep 30, 2019
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Jun 15, 2020
This may not be the desired solution as it commits to close as soon as there are no windows.
A future change could address fyne-io#467 to add a veto-close function.
andydotxyz added a commit that referenced this issue Jun 16, 2020
This may not be the desired solution as it commits to close as soon as there are no windows.
A future change could address #467 to add a veto-close function.
andydotxyz pushed a commit that referenced this issue Aug 14, 2020
…efore anything is done (#1180)

Add SetCloseIntercept to be able to veto window close.
Be aware client code should call window.Close() if the action was desired.

Fixes #467
@andydotxyz
Copy link
Member

This was completed a while back :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants