Improve focus handling in the Remote Access Connection dialog (#18031)
Closes #17973
Summary of the issue:
Focus handling in the "Connect to another computer" dialog is
suboptimal.
Description of user facing changes
* When connecting using a remote relay server, after a key is generated
by the server, the key field is automatically focused.
* When connecting using a local relay server, after detecting the
external IP, the external IP field is automatically focused.
* When attempting to initiate a connection with a blank host/port and/or
key field, the first erroneously empty field is focused after the error
dialog is dismissed.
Description of development approach
Focusing key/external IP fields:
Since the indeterminate progress dialog is shown asynchronously, we
can't know for certain when the connection dialog will be focusable
again. This is problematic as we can only (successfully) call `SetFocus`
on children of focusable dialogs.
To work around this, bind an event handler to the dialog after
successfully generating a key/detecting the external IP that:
* Is triggered by `wx.EVT_ACTIVATE`, so it fires when the dialog is
focused (as this only happens when the dialog is focusable).
* Focuses the key or external IP field, as appropriate.
* Unbinds itself, so the event is only called the once.
Focusing the first empty control:
Add an `if` statement that selects the appropriate control based on
which one is empty.
Testing strategy:
Attempted to perform a variety of legal and illegal operations with the
dialog.
Known issues with pull request:
None.