Creating EditBoxes in option panels

I stumbled across a few issues while creating a new option panel, so this might be an interesting sidenote for other addon authors:
If you want to implement an EditBox-Widget in an option panel, you must disable the autoFocus for this EditBox. Otherwise, it would catch all inputs from the keyboard after login and you won’t be able to do anything. There are two ways to do that:

  • XML: When creating the EditBox, set the attribute to false
    <EditBox (...) autoFocus="false">
  • LUA:
    EditBox:SetAutoFocus(false)

If you fill in text via ‘EditBox:SetText(<string>)’ you will also need to set the cursor position to zero in order to actually see the text you filled in. To do this, use: ‘EditBox:SetCursorPosition(0)’.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.