comparison SkeletonKey/BindingsFrame.lua @ 49:9a9d7f2a7c07

- handle mouse input with string.upper - process input for the whole bindings frame region when a slot is activated - fix various errors arising from handler inconsistencies
author Nenue
date Thu, 18 Aug 2016 01:34:22 -0400
parents daff39af0c6d
children 1aba8a6fd4a9
comparison
equal deleted inserted replaced
48:83b941c7e260 49:9a9d7f2a7c07
55 local restingAlpha = 0.7 55 local restingAlpha = 0.7
56 local fadeTime, fadeDelay = .30, 0.15 56 local fadeTime, fadeDelay = .30, 0.15
57 local saveButton 57 local saveButton
58 58
59 local KeyButton_OnKeyDown = function(self, key) 59 local KeyButton_OnKeyDown = function(self, key)
60 if key == 'ESCAPE' or key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then
61 return
62 end
63 kb.saveTarget.border:SetColorTexture(1,1,1,1) 60 kb.saveTarget.border:SetColorTexture(1,1,1,1)
64 end 61 end
65 local KeyButton_OnKeyUp = function(self, key) 62 local KeyButton_OnKeyUp = function(self, key)
63
64 kb.UpdateSlot(kb.saveTarget)
66 if key == 'ESCAPE' then 65 if key == 'ESCAPE' then
67 kb.DeactivateSlot(kb.saveTarget) 66 kb.DeactivateSlot(kb.saveTarget)
68 kb.ui() 67 kb.ui()
69 return 68 return
70 end 69 end
71 70
72 if key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then 71 if key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then
73 return 72 return
74 end 73 elseif kb.saveTarget then
75 74
76 if kb.SaveSlot(kb.saveTarget, key) then 75 if kb.SaveSlot(kb.saveTarget, key) then
77 if not (kb.db.stickyMode or kb.db.hoverInput) then 76 if not (kb.db.stickyMode or kb.db.hoverInput) then
78 77
79 kb.DeactivateSlot(kb.saveTarget) 78 kb.DeactivateSlot(kb.saveTarget)
80 end 79 end
81 kb.ui() 80 kb.ui()
82 end 81 end
82 end
83
84
83 end 85 end
84 86
85 local KeyButton_OnClick = function(self, click) 87 local KeyButton_OnClick = function(self, click)
86 print(self:GetName(), 'OnMouseDown', click) 88 print(self:GetName(), 'OnMouseDown', click)
87 local cursorType = GetCursorInfo() 89 local cursorType = GetCursorInfo()
101 103
102 end 104 end
103 elseif click == 'RightButton' then 105 elseif click == 'RightButton' then
104 kb.ReleaseSlot(self) 106 kb.ReleaseSlot(self)
105 kb.ui() 107 kb.ui()
108 elseif kb.saveTarget then
109
110 if kb.SaveSlot(kb.saveTarget, string.upper(click)) then
111 if not (kb.db.stickyMode or kb.db.hoverInput) then
112
113 kb.DeactivateSlot(kb.saveTarget)
114 end
115 kb.ui()
116 end
106 end 117 end
107 end 118 end
108 119
109 local KeyButton_OnDragStart = function(self) 120 local KeyButton_OnDragStart = function(self)
110 kb.PickupSlot(self) 121 kb.PickupSlot(self)
387 --- Retrieves button at index; creates said button and instates any stored parameters 398 --- Retrieves button at index; creates said button and instates any stored parameters
388 399
389 400
390 kb.ActivateSlot = function(button) 401 kb.ActivateSlot = function(button)
391 kb.saveTarget = button 402 kb.saveTarget = button
392 kb:SetScript('OnKeyUp', KeyButton_OnKeyUp) 403 kb:SetScript('OnKeyUp', function(self, key) KeyButton_OnKeyUp(button, key) end)
393 kb:SetScript('OnKeyDown', KeyButton_OnKeyDown) 404 kb:SetScript('OnKeyDown', function(self, key) KeyButton_OnKeyDown(button, key) end)
405 kb:SetScript('OnMouseUp', function(self, key) KeyButton_OnKeyUp(button, key) end)
394 kb.savingText:ClearAllPoints() 406 kb.savingText:ClearAllPoints()
395 kb.savingText:SetParent(button) 407 kb.savingText:SetParent(button)
396 kb.savingText:SetPoint('BOTTOMLEFT', button, 'TOPLEFT', 0, 0) 408 kb.savingText:SetPoint('BOTTOMLEFT', button, 'TOPLEFT', 0, 0)
397 end 409 end
398 410
399 kb.DeactivateSlot = function(button) 411 kb.DeactivateSlot = function(button)
400 kb.saveTarget = nil 412 kb.saveTarget = nil
401 kb:SetScript('OnKeyUp', nil) 413 kb:SetScript('OnKeyUp', nil)
402 kb:SetScript('OnKeyDown', nil) 414 kb:SetScript('OnKeyDown', nil)
415 kb:SetScript('OnMouseUp', nil)
403 end 416 end
404 417
405 418
406 --- push current information into living UI 419 --- push current information into living UI
407 kb.ui = function(force) 420 kb.ui = function(force)