Alert Doesn't Get Focus

I have a button that, on clicking, does the following :

pf=MyForm()
alert(pf)

The form shows in a pop up alert box as expected, but the button underneath still has focus. If I press enter without doing anything else then it will continue to click the parent form’s button (stacking up alert boxes).

I discovered this because I was trying to set the focus to a text box in the alert form. That fails because, I’m guessing, the alert box doesn’t actually have focus itself. The on show event fires but you have to click the popup to get focus moved.

I think I reported this a while back and you fixed it, though I might be wrong.

(edit) - ahah! found it. Looks like you did fix this once :

I solved the problem using a timer.
Adding a timer to the form that contains the text box and this code to its tick event does the trick:

  def timer_1_tick(self, **event_args):
    self.timer_1.interval = 0
    self.input_box.focus()
3 Likes