MessageDialog and MsgBox not always active window. I think it should be even if the main window not active. For example when I drag and drop a file to my window.
On Windows? @anon20074439 knows a bit about this bug. I’ve just pinged him, so let’s see what he can tell us
For sure on windows and as far as I remember on mac too. I’ll check out mac tomorrow.
Ya it’s bugged, happens in the ide too. Afk a bit so I can’t check feedback. I’ll come back here later.
On macOS too… since the down of time
It is one of teh reasons why I use System.DebugLog or I implement my own window (depend of the use).
OK, then an acceptable workaround could be set the window active before call MessageDialog/MsgBox.
Is that possible?
It might be, but I think Xojo does that and it doesn’t work in some cases as you sometimes end up with the window behind the IDE or other windows and you’re left wondering why you can’t click the IDE so I can’t say for certain without some testing. I can’t find anything about it in feedback, but that’s no surprise. If you do want to do it that way, search for BringWindowToTop on the forum and there should be some posts telling you how to use write the declare.
For MessageBox, there’s no way to set MB_SETFOREGROUND and/or MB_TOPMOST. As for MessageDialog, you can’t get a handle to it before it’s shown so it’s not trivial to step in and force it to the front. Unfortunately, the way to do it correctly would be to write your own.
what an annoying bug.!!!
I have a menu and an Exit option and it calls
messagedialog and it hides behind another window…
so no way exit the application…
I have a strategy to solve this problem:
- Create a MessageDialog
- Before showing it, save a reference to it in the App module (call it cMessageDialog)
- In the App module, add a method (call it cMessageDialogToFront) if cMessageDialog <> Nil then cMessageDialog.actionButton.Visible = True
- Before showing the dialog, add a line: Timer.CallLater( 30, AddressOf App.cMessageDialogToFront )
- Then: call Show or ShowModal
- Just to be safe, after the call: App.cMessageDialog = Nil
This seems to work, but I’m not sure because the bug is impossible to reliably reproduce.
- Don’t forget: also put cMessageDialogToFront in App.Activate
I can’t follow step 2, can you please give me a sample project. Thank you.
It would be better for you to learn how to follow the instructions. All it takes is understanding what’s being said, and knowing where to go in the IDE to do the steps.
For step 2: You have to add a property to the App module:
cMessageDialog as MessageDialog
You’ll find the App module at the upper left in a list in the IDE, then use a menu to add a property (or key shortcut).
Then this step says: in whatever method you’re writing where you create the MessageDialog (call it d), write this line:
App.cMessageDialog = d
That’s what’s meant by “save a reference to the MessageDialog in the App module”.
OK, I can follow now, thanks. But still not working.
I test this with a button with Timer.CallLater(1000, AddressOf ShowDialog) to open the MessageDialog a second later so I have time to activate another window. It’s still opening in the background unfortunately.
Please try without activating another window.
Ah, I just realized there are two issues here. My initial problem is MessageDialog and MsgBox not became active window if the program is in the background.