Has anyone else noticed that occasionally an OpenFileDialog.ShowModal results in the focus and keyboard activity remaining on the window in the background? I’ve not bee able to track it down or reproduce it but it certainly seems to happen from time to time.
I have a similar issue with 2021r2.1 under the following circumstances:
Windows target.
In the MouseDown (or MouseUp) event of a Canvas on Window1, instantiate a Window2 and call a method on it that invokes Self.Showmodal.
No amount of ClearFocus/SetFocus seems to be able to set the focus to a TextField on WIndow2. User has to click on the TextField before text can be entered.
Maybe I misunderstand modal, then… I’ll not rule that out.
To me, one window is modal to a parent window, which it (should) effectively disable until the modal window is closed.
It’s not just a ‘show this window until it is closed’ thing, is it?
What happens if you have a Module method as Follows:
Function GetAnswer( oWindow as DesktopWindow ) as String
Return oWindow.ShowModal.GetAnswer
End Function
// Calling it as:
Answer = GetAnswer( Window2 )
Which is what I see as well, albeit with my own modal dialog window rather than your OpenFileDialog. But if you think my case is irrelevant to yours, feel free to ignore. Just thought it might help.
You’re correct, our issues are unrelated. Thanks for inspiring me to look a little more closely, though - it turns out that a call to RemoteControlMBS.WinBringWindowToTop was preventing the TextField from getting the focus as expected
Input validation can of course be performed by the calling code as necessary, and I’ve never encountered a case where I needed to differentiate between the user clicking OK with the text field empty or clicking Cancel or entering text then clearing the text and then clicking OK. In the majority of cases I use my GetTextWindow for password input, so if the user clears the text field it’s simply an invalid password and the window does the “shake” thing.
It is not needed - apparently at some point in the past I thought it was, maybe trying to open it from another modal window and they ended up fighting for frontmost. When I abandoned that, I neglected to remove the MBS call, which I assumed was benign.