Hey guys, Working with textBox widgets, however I've run into some confusion. The widget function widget.hasFocus() is void, but the lua doc seems to say it will return a bool. Confused as to how to use this, or check textBox focus otherwise. Code: `void` widget.hasFocus(`String` widgetName) Returns whether the specified widget is currently focused.
It does return a boolean. Just make sure the widget name is correct. For example, if your "tbx" is in a scroll area "scroll" your widget name should be "scroll.tbx".
Thanks! However, I've got another issue with textBox widgets. I found out the reason my testing for that boolean wasn't returning values was because I wasn't entering the "escapeKey" callback function at all (which was what I was having check for focus). Where I'm going wrong is probably not knowing how to format the config file for escapeKey or misunderstanding how focus works. What I'm trying to do is: 1. User is typing in textbox 2. User presses [ESC] 3. Instead of exiting the window, the textbox unfocuses What happens: Window closes Here's a snippet of my config with my textBoxes (They're all inside "gui":{}, but I decided to omit the rest of my widgets for sake of clarity) No scroll areas being used Code: "subtitle":{ "type": "textbox", "hint": "^orange;<^white;Subtitle^orange;>", "position": [15,190], "enterKey": "loseFocus", "escapeKey": "loseFocus" }, "desc":{ "type": "textbox", "hint": "^orange;<^white;Description^orange;>", "position": [15,105], "enterKey": "loseFocus", "escapeKey": "loseFocus" }, "name":{ "type": "textbox", "hint": "^orange;<^white;STATS HEADER^orange;>", "position": [152,197], "enterKey": "loseFocus", "escapeKey": "loseFocus" } Code: "scriptWidgetCallbacks" : ["configure", "leftClick", "rightClick", "subtitle", "desc", "name", "loseFocus"], "scripts" : ["/interface/scripted/cpu_configurator/interfacecpu_configurator.lua"] (loseFocus for enterKey works perfectly fine)
I assume you found escapeKey in an existing interface. Did you try pressing escape there? It may just be the way things work :/