Mercurial > wow > skeletonkey
diff SkeletonKey/BindingsUI.lua @ 16:cdd387d39137
filename refactor
author | Nenue |
---|---|
date | Fri, 29 Jul 2016 21:18:15 -0400 |
parents | 32d64e42ec9b |
children | 500f9b2bd9ac |
line wrap: on
line diff
--- a/SkeletonKey/BindingsUI.lua Fri Jul 29 03:27:15 2016 -0400 +++ b/SkeletonKey/BindingsUI.lua Fri Jul 29 21:18:15 2016 -0400 @@ -2,7 +2,7 @@ -- BindingsUI.lua -- Created: 7/28/2016 3:39 PM -- %file-revision% --- +-- Code piecing the interface together local kb, print = LibStub("LibKraken").register(KeyBinder, 'KeySlot') local BINDS_PER_ROW = 2 @@ -38,17 +38,23 @@ local fadeTime, fadeDelay = .30, 0.15 local numButtons = BINDS_PER_ROW * 8 local saveButton -local KeyButton_OnKeyDown = function(self, key) - kb.StoreBinding(self, key) +local KeyButton_OnKey = function(self, key) + kb.StoreBinding(self.saveTarget, key) + kb:SetScript('OnKeyUp', nil) + kb:SetScript('OnKeyDown', nil) end + local KeyButton_OnClick = function(self, click) print(self:GetName(), 'OnMouseDown', click) + local cursorType = GetCursorInfo() if click == 'LeftButton' then - kb.DropToSlot(self) + if cursorType then + kb.DropToSlot(self) + else + kb.ActivateSlot(self) + end elseif click == 'RightButton' then kb.ReleaseSlot(self) - else - kb.StoreBinding(self, click:upper()) end end @@ -103,8 +109,6 @@ if not self.active then -- only set this handler when the button is activated/mouseOver self.active = true - self:SetScript('OnKeyDown', KeyButton_OnKeyDown) - kb.statustext:SetText(self.statusText .. ': '..self.actionName) kb.bindingstext:SetText(self.bindingText) kb.fadeStep = 0 @@ -261,6 +265,12 @@ end +kb.ActivateSlot = function(self) + kb.saveTarget = self + kb:SetScript('OnKeyUp', KeyButton_OnKey) + kb.bg:SetColorTexture(0,.5,0,1) +end + --- push current information into living UI kb.ui = function(force) for i, module in ipairs(kb.modules) do