mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-04 05:34:51 +00:00
Setting Modal = true in BrowserOptions does not work #767
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lukebordonaro on GitHub (Feb 21, 2022).
Version: 13.5.1
Target: windows
If you set
BrowserWindowOptions.Modal = truewhen creating a newBrowserWindow, the created window will not be a modal window even after setting the parent.Consider this code:
The observed behavior of the child window is that it is NOT a modal window, and you can still interact with the main window (
parent). The value ofisModalin theOnShowhandler isfalse, too.I haven't investigated this, but it's possible that for modal windows to work the
parentmust be set inside theBrowserWindowOptions: https://www.electronjs.org/docs/latest/api/browser-window/#modal-windows@lukebordonaro commented on GitHub (Feb 21, 2022):
Update: I tested some changes locally and can confirm that setting a
parentin theBrowserWindowOptionsfixes the issue. Would you like me to make a PR with my test changes?@danatcofo commented on GitHub (Feb 21, 2022):
Interesting... id be interested to see if the javascript version of the add parent works or not. If it does work, sounds like a bug in the implementation of that function.
@lukebordonaro commented on GitHub (Feb 21, 2022):
The call to
SetParentWindowdoes work as expected, for the most part. Calling this in C# does change the grouping of the windows on my taskbar.I'm thinking this is a side-effect of native APIs. Window types may need to be set when the window is created, which is probably why the Electron docs state "to create a modal window, you have to set both parent and modal options" (emphasis mine).
@danatcofo commented on GitHub (Feb 21, 2022):
Well if thats the case then this is less a bug and more of a documentation issue. You might add to the readme.
I think more and more we need a howto or faq or something about some of these common issues.
@lukebordonaro commented on GitHub (Feb 21, 2022):
@danatcofo unfortunately it's not just a documentation issue. To create a modal window, ElectronNET needs to add the
Parentproperty toBrowserWindowOptions. It's currently impossible to create a modal window in C#.@monisha-soliton commented on GitHub (Mar 18, 2022):
Hi @MutatedGamer
We are facing the same issue. We would like to try out the fix you have made locally. Is it possible for you to share the updated code for us to try out? If sharing the code is not possible by any chance please let us know the list of changes to try out the fix.
Also, please let us know if there is any plan to release the fix anytime soon
@lukebordonaro commented on GitHub (Mar 18, 2022):
@MonishaMaryA I'll submit a pull request this weekend with the changes I made to get it working
@monisha-soliton commented on GitHub (Mar 22, 2022):
@MutatedGamer
Thanks for the update. Let us know once you submit a pull request. Do you have any idea on when the pull request will be merged and released?
@lukebordonaro commented on GitHub (Mar 22, 2022):
@MonishaMaryA I created PR https://github.com/ElectronNET/Electron.NET/pull/673
I cannot speak for when it would likely get merged or released. I've been working off a local build of the library that I push to a local filesystem nuget feed.
@monisha-soliton commented on GitHub (Mar 22, 2022):
Sure @MutatedGamer
Thank you so much for updating the fix and sharing the PR. We will also try to build locally and work.
@monisha-soliton commented on GitHub (Mar 24, 2022):
@robertmuehsig , @GregorBiswanger
Could you please let us know when the pull request #673 will be merged and released?
@monisha-soliton commented on GitHub (May 4, 2023):
Hi @GregorBiswanger ,
In the latest release 23.6.1, this fix is not reflected. Could you please check on this issue again?
@monisha-soliton commented on GitHub (May 9, 2023):
Hi @GregorBiswanger and @FlorianRappl
I see that the PR 673 was merged to master branch which is now stale. We need this to be fixed as soon as possible. Could you please let us know if there is any possibility for fixing this and release the update any time sooner