This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Live
PTR
10.2.7
PTR
10.2.6
Beta
Problems with EditBox [lua] [Solved]
Post Reply
Return to board index
Post by
janniie
I'm trying to create an editbox to use as a search window for my addon. There are a few problems...
Whenever I type text while the window is up, no text at all is showing. The only thing visible is the text cursor, which doesn't move. However, the text i write is still recorded because GetText() gives exactly what I've typed in. As for the cursor, It wont even move when I SetCursorPosition(GetNumLetters()) (GetNumLetters() shows the right amount). To bypass this I created a fontstring to show over the box but it's just horrible...
I did not use any templates to create the box.
I am fairly new to LUA, and it's mostly self learned by trial and error, so I know it's not optimal coding, but this is what I've got:
local function Create_EditBox(name,parent)
local frame = CreateFrame("EditBox",name,parent)
frame:SetWidth(300)
frame:SetHeight(150)
frame:SetPoint("CENTER",UIParent)
frame:SetTextInsets(20, 20, 55, 55)
frame:SetMaxLetters(100)
local backdrop =
{
bgFile = "Interface/ACHIEVEMENTFRAME/UI-Achievement-Parchment Horizontal",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = false,
tileSize = 16,
edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
}
frame:SetBackdrop(backdrop)
frame:SetScript("OnChar",function(self,userInput,...)
local Text = self:GetText() or ""
self:SetText(Text..""..userInput)
end)
frame:SetScript("OnHide",function(self)
self:SetText("")
end)
local Box = CreateFrame("Frame",nil,frame)
Box:SetWidth(280)
Box:SetHeight(40)
Box:SetPoint("CENTER",frame,"CENTER")
local backdrop2 =
{
bgFile = nil,
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = false,
tileSize = 16,
edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
}
Box:SetBackdrop(backdrop2)
btn = CreateButton(name.."Btn",frame)
Anchor =
{
Point = "BOTTOM",
RelativeFrame = frame,
RelativePoint = "BOTTOM",
xOfs = 0,
yOfs = 10
}
Modify_Button(btn,"Search",40,120,nil,Anchor,function(self)
local search = self:GetParent():GetText()
Search_Data(search)
end)
local close = CreateFrame("Button",nil,frame,"UIPanelCloseButton")
close:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-4,-4)
frame:Hide()
return frame
end
Post by
ouhac
Make shure to position your EditBox (SetPoint), made mine appear on screen after doing so. Also setting SetFrameStrata to a (higher) level might solve some issues.
local f = CreateFrame("EditBox", "logEditBox", buyFrame, "InputBoxTemplate")
f:SetFrameStrata("DIALOG")
f:SetSize(300,300)
f:SetAutoFocus(false)
f:SetText("Lolo lo lo")
f:SetPoint("TOPLEFT", 30, -30)
(i know, old thead, but sill valuable for people who search same issue on google and land on this page)
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.