Text fields losing focus

It used to be if a text field had focus and you messed with the interface to do something like add items to a mail or link an item in text, the text field would maintain focus.

But that changed a couple months ago and you got to go through a process of re focusing the text field.

Is there a setting or a way to get text fields to work like they did before?

This is possible to do. I coded a workaround in CTMod to make the mail frame less annoying. Here’s the method:

  • Listen for OnEditFocusGained on any mail-frame edit boxes, and then trigger a flag to say that focus is on said box;
  • Listen for OnMouseDown on any buttons that a person might click while preparing a message (ie, StackSplitFrame.OkayButton or ContainerFrame1Item1) and restore focus back the edit box which had it
  • Listen for OnEditFocusLost and, when it happens, wait 0.0001 seconds to see if either a new EditBox gained focus or if in fact nothing has focus; and if nothing has focus then clear the flag.

https://www.curseforge.com/wow/addons/ctmod

Look in CT_MailMod/CT_MailMod_StockUI.lua at lines 1205 to 1284

1 Like

This should fix it https://www.curseforge.com/wow/addons/unregisterglobalmouse

1 Like

Don’t forget autofocus will “prevent” this behavior too, if your addon/dialog lends itself to the text box keeping focus before being dismissed.

I say “prevent” because even with autofocus enabled, the editbox will get an OnEditFocusLost event when someone clicks elsewhere; though it will grab focus right back. One of my addons dismisses a panel when the editbox loses focus, so I added a C_Timer.After to confirm it still has focus before dismissing the panel.