Back to Home

ESO Lua File v101039

libraries/zo_editboxes/zo_editbox.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-----------------------
-- ZO_EditBox
-----------------------
ZO_EditBox = ZO_CallbackObject:Subclass()
function ZO_EditBox:New(...)
    local object = ZO_CallbackObject.New(self)
    object:Initialize(...)
    return object
end
function ZO_EditBox:Initialize(control)
    self.control = control
    self.edit = control:GetNamedChild("Edit")
    self.empty = control:GetNamedChild("Empty")
    self.edit:SetHandler("OnTextChanged", function() self:Refresh() end)
end
function ZO_EditBox:SetDefaultText(defaultText)
    self.edit:SetDefaultText(defaultText)
end
function ZO_EditBox:SetEmptyText(emptyText)
    self.empty:SetText(emptyText)
end
function ZO_EditBox:GetText()
    return self.edit:GetText()
end
function ZO_EditBox:SetText(text)
    local hideEmptyText = text ~= ""
    self.empty:SetHidden(hideEmptyText)
    self.edit:SetText(text)
end
function ZO_EditBox:Refresh()
    local hideEmptyText = self:GetText() ~= ""
    self.empty:SetHidden(hideEmptyText)
end
function ZO_EditBox:GetControl()
    return self.control
end
function ZO_EditBox:GetEditControl()
    return self.edit
end
function ZO_EditBox:TakeFocus()
    return self.edit:TakeFocus()
end
function ZO_EditBox:LoseFocus()
    return self.edit:LoseFocus()
end