comparison AceGUIWidget-DoTimerEditBoxDropDown.lua @ 54:6d5fcbdc0590

DoTimerEditBoxDropDown widget to ver 5, warn (once) about missing item cache entries in the filter list dropdown.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Sat, 07 Apr 2012 04:59:27 +0000
parents 822b6ca3ef89
children
comparison
equal deleted inserted replaced
53:7af58a7dce7d 54:6d5fcbdc0590
1 local Type, Version = "EditBoxDropDown", 3 1 local Type, Version = "EditBoxDropDown", 5
2 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) 2 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
3 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end 3 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
4 4
5 --[[ 5 --[[
6 This is a from-scratch AceGUI-style implementation of the combination drop- 6 This is a from-scratch AceGUI-style implementation of the combination drop-
18 Version 2 is a rehash to follow the same form of the rest of the AceGUI widgets 18 Version 2 is a rehash to follow the same form of the rest of the AceGUI widgets
19 after their rewrite, and to work with the new EditBox behavior. 19 after their rewrite, and to work with the new EditBox behavior.
20 20
21 Version 3 adds the EditBoxDropDownOptionControl variant, specifically for use 21 Version 3 adds the EditBoxDropDownOptionControl variant, specifically for use
22 as a 'dialogControl' in AceConfig option tables. Details follow; the more 22 as a 'dialogControl' in AceConfig option tables. Details follow; the more
23 disappointing restrictions are because AceConfig never gives the end user any 23 disappointing restrictions are because AceConfig never gives the programmer any
24 direct link to the widgets in use. 24 direct link to the widgets in use.
25 - 'desc' option field ignored 25 - 'desc' option field ignored
26 - 'name' field may contain an embedded tab ('\t') followed by more text to be 26 - 'name' field may contain an embedded tab ('\t') followed by more text to be
27 used as the tooltip text when hovering over the editbox field 27 used as the tooltip text when hovering over the editbox field
28 - 'get' field must be a function, returning a function to be used as the 28 - 'get' field must be a function, returning a function to be used as the
29 OnTextEnterPressed callback; this is typically how new entries should be 29 OnTextEnterPressed callback; this is typically how new entries should be
30 added to data 30 added to data
31 - 'values' field must be a function, returning the usual list of entries, PLUS 31 - 'values' field must be a function, returning the usual list of entries, PLUS
32 the callback used for 'get', e.g., 32 the callback used for 'get' as a key, e.g.,
33 values = function() 33 values = function()
34 local ret = build_real_dropdown_values() 34 local ret = build_real_dropdown_table()
35 ret[get_callback] = true -- assuming "function get_callback (widget, event, text)" 35 ret[get_callback] = true -- assuming "function get_callback (widget, event, text) .... end"
36 return ret 36 return ret
37 end 37 end
38 The callback will be immediately removed from the table, but is required to 38 The callback will be immediately removed from the table, but is required to
39 be present to pass tests in the AceConfig source. 39 be present to pass tests in the AceConfig source.
40 - 'set' receives the key of the dropdown table, but that entry will already be 40 - 'set' receives the key of the dropdown table, but that entry will already be
41 removed by the time the 'set' function is called 41 removed by the time the 'set' function is called
42 42
43 Version 4 was never released.
44
45 Version 5 adds the OnDropdownShown callback.
46
43 47
44 EditBoxDropDown API 48 EditBoxDropDown API
45 49
46 :SetLabel(txt) 50 :SetLabel(txt)
47 forwards to the editbox's SetLabel 51 forwards to the editbox's SetLabel
71 75
72 OnListItemClicked 76 OnListItemClicked
73 similar to a Dropdown widget's OnValueChanged, the key and value from the 77 similar to a Dropdown widget's OnValueChanged, the key and value from the
74 table given to :SetList are passed 78 table given to :SetList are passed
75 79
76 80 OnDropdownShown
77 farmbuyer 81 when the down arrow is clicked to display the list
82
83
84 farmbuyer@gmail.com
78 ]] 85 ]]
79 86
80 local button_hover_text_default = "Click on entries to remove them." 87 local button_hover_text_default = "Click on entries to remove them."
81 local maps -- from actual editbox frame back to this widget 88 local maps -- from actual editbox frame back to this widget
82 89
140 else 147 else
141 dd.is_on = true 148 dd.is_on = true
142 local t = BuildList(button.obj) 149 local t = BuildList(button.obj)
143 EasyMenu (t, button.obj.dropdown, button.obj.frame, 0, 0, "MENU") 150 EasyMenu (t, button.obj.dropdown, button.obj.frame, 0, 0, "MENU")
144 PlaySound("igMainMenuOptionCheckBoxOn") 151 PlaySound("igMainMenuOptionCheckBoxOn")
152 button.obj:Fire("OnDropdownShown")
145 end 153 end
146 end 154 end
147 155
148 local function Button_OnEnter (button) 156 local function Button_OnEnter (button)
149 if button.tooltip_text then 157 if button.tooltip_text then
151 GameTooltip:SetText(button.tooltip_text, nil, nil, nil, nil, 1) 159 GameTooltip:SetText(button.tooltip_text, nil, nil, nil, nil, 1)
152 end 160 end
153 end 161 end
154 162
155 163
164 --local base_SetWidth = AceGUI.WidgetBase.SetWidth
156 local methods = { 165 local methods = {
157 ["OnAcquire"] = function (self) 166 ["OnAcquire"] = function (self)
158 self:SetHeight(20) 167 self:SetHeight(20)
159 self:SetWidth(100) 168 self:SetWidth(100)
160 self.button.tooltip_text = button_hover_text_default 169 self.button.tooltip_text = button_hover_text_default
162 self.editbox:DisableButton(true) 171 self.editbox:DisableButton(true)
163 172
164 maps = maps or {} 173 maps = maps or {}
165 maps[self.editbox.editbox] = self 174 maps[self.editbox.editbox] = self
166 end, 175 end,
167 176 --[=[
177 ["SetWidth"] = function (self, width)
178 print("got",width)
179 base_SetWidth(self, width)
180 self.frame.width = width + 45
181 end,
182
183 ["GetWidth"] = function (self)
184 return self.frame:GetWidth() + 45
185 end,
186 ]=]
168 ["OnRelease"] = function (self) 187 ["OnRelease"] = function (self)
169 self.frame:ClearAllPoints() 188 self.frame:ClearAllPoints()
170 self.frame:Hide() 189 self.frame:Hide()
171 self.editbox.tooltip_text = nil 190 self.editbox.tooltip_text = nil
172 self.button.tooltip_text = nil 191 self.button.tooltip_text = nil
237 -- formal containter. Inspired by new-style InteractiveLabel. 256 -- formal containter. Inspired by new-style InteractiveLabel.
238 local editbox = AceGUI:Create("EditBox") 257 local editbox = AceGUI:Create("EditBox")
239 local frame = editbox.frame 258 local frame = editbox.frame
240 editbox:SetHeight(20) 259 editbox:SetHeight(20)
241 editbox:SetWidth(100) 260 editbox:SetWidth(100)
242 frame:SetWidth(frame:GetWidth()+6) 261 --frame:SetWidth(frame:GetWidth()+15)
262 --frame.width = frame:GetWidth() + 15
243 editbox:SetCallback("OnEnter", ddEditBox_OnMouseEnter) 263 editbox:SetCallback("OnEnter", ddEditBox_OnMouseEnter)
244 editbox:SetCallback("OnLeave", ddEditBox_OnMouseLeave) 264 editbox:SetCallback("OnLeave", ddEditBox_OnMouseLeave)
245 editbox:SetCallback("OnEnterPressed", ddEditBox_OnEnterPressed) 265 editbox:SetCallback("OnEnterPressed", ddEditBox_OnEnterPressed)
246 editbox.editbox:SetScript("OnEditFocusGained", ddEditBox_Clear) 266 editbox.editbox:SetScript("OnEditFocusGained", ddEditBox_Clear)
247 editbox.editbox:SetScript("OnEditFocusLost", ddEditBox_Reset) 267 editbox.editbox:SetScript("OnEditFocusLost", ddEditBox_Reset)