comparison options.lua @ 104:04198c8d0717

Don't set a default keybinding, but rather change the associated option to not be clunky and gross.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Sun, 05 Aug 2012 16:53:07 +0000
parents dc8a23a47b03
children 646c9b41aaed
comparison
equal deleted inserted replaced
103:dc8a23a47b03 104:04198c8d0717
181 -- possible keybindings 181 -- possible keybindings
182 do 182 do
183 local pair = AceGUI:Create("InlineGroup") 183 local pair = AceGUI:Create("InlineGroup")
184 pair:SetLayout("List") 184 pair:SetLayout("List")
185 pair:SetRelativeWidth(0.49) 185 pair:SetRelativeWidth(0.49)
186 pair:SetTitle("Keybinding for '/ouroloot'") 186 pair:SetTitle('Keybinding for "/ouroloot toggle"')
187 local editbox, checkbox 187 local checkbox, button
188 --[=[
188 editbox = mkbutton("EditBox", nil, opts.keybinding_text, 189 editbox = mkbutton("EditBox", nil, opts.keybinding_text,
189 [[Keybinding text format is fragile! (All caps, ALT then CTRL then SHIFT.) Relog to take effect.]]) 190 [[Keybinding text format is fragile! (All caps, ALT then CTRL then SHIFT.) Relog to take effect.]])
190 editbox:SetFullWidth(true) 191 editbox:SetFullWidth(true)
191 editbox:SetLabel("Keybinding text") 192 editbox:SetLabel("Keybinding text")
192 editbox:SetCallback("OnEnterPressed", function(_w,event,value) 193 editbox:SetCallback("OnEnterPressed", function(_w,event,value)
193 opts.keybinding_text = value 194 opts.keybinding_text = value
194 end) 195 end)
195 editbox:SetDisabled(not opts.keybinding) 196 editbox:SetDisabled(not opts.keybinding)
197 ]=]
196 checkbox = mktoggle('keybinding', "Register keybinding", 1, 198 checkbox = mktoggle('keybinding', "Register keybinding", 1,
197 [[Register a keybinding to toggle the loot display. Relog to take effect.]], 199 [[Whether to register a keybinding to toggle the loot display. Relog to take effect.]],
198 function (_w,_,value) 200 function (_w,_,value)
199 opts.keybinding = value 201 opts.keybinding = value
200 editbox:SetDisabled(not opts.keybinding) 202 --editbox:SetDisabled(not opts.keybinding)
203 button:SetDisabled(not opts.keybinding)
201 end) 204 end)
202 checkbox:SetFullWidth(true) 205 checkbox:SetFullWidth(true)
203 pair:AddChild(checkbox) 206 button = mkbutton("Keybinding", nil, "",
204 pair:AddChild(editbox) 207 -- This wording is not quite accurate, but auto-l10n is nice.
208 _G.BIND_KEY_TO_COMMAND:format([['/ouroloot toggle']]))
209 button:SetFullWidth(true)
210 --button:SetLabel("this is label text")
211 button:SetKey(opts.keybinding_text)
212 button.msgframe:SetToplevel(true) -- XXX ace3 ticket #305
213 button:SetCallback("OnKeyChanged", function(_b,event,value)
214 local possible_prev = opts.keybinding_text
215 opts.keybinding_text = value
216 -- If they were already binding something at login, try updating.
217 if not _G.OuroLootBindingOpen then return end
218 if possible_prev and #possible_prev > 0 then
219 addon:Print("Trying to unbind previous %s key.", possible_prev)
220 SetBinding (possible_prev, nil)
221 end
222 if value and #value > 0 then
223 addon:Print("Trying to bind new %s key.", value)
224 if SetBindingClick (value, "OuroLootBindingOpen") then
225 local c = GetCurrentBindingSet()
226 if c == ACCOUNT_BINDINGS or c == CHARACTER_BINDINGS then
227 SaveBindings(c)
228 end
229 end
230 end
231 end)
232 pair:AddChildren (checkbox, button)--, editbox)
205 container:AddChild(pair) 233 container:AddChild(pair)
206 end 234 end
207 235
208 -- replacement for slashloot 236 -- replacement for slashloot
209 do 237 do