Mercurial > wow > reaction
comparison classes/ReAction.lua @ 10:f3a7bfebc283
Version 0.33
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Tue, 20 Mar 2007 21:37:38 +0000 |
parents | c05fd3e18b4f |
children | 90bf38d48efd |
comparison
equal
deleted
inserted
replaced
9:650f75d08952 | 10:f3a7bfebc283 |
---|---|
4 -- It does not define any layout or actual action functionality, | 4 -- It does not define any layout or actual action functionality, |
5 -- which is deferred to derived classes. | 5 -- which is deferred to derived classes. |
6 -- | 6 -- |
7 -- ReAction implements the ReBar.IButton interface. It is designed to be used with ReBar | 7 -- ReAction implements the ReBar.IButton interface. It is designed to be used with ReBar |
8 -- for grouping and laying out buttons. | 8 -- for grouping and laying out buttons. |
9 -- | |
10 -- ReAction supports the ReBound keybinding interface (only). | |
11 -- | 9 -- |
12 -- Each instance of a ReAction-derived object is associated with a single action | 10 -- Each instance of a ReAction-derived object is associated with a single action |
13 -- button frame, which may or may not have a one-to-one mapping with actionID. | 11 -- button frame, which may or may not have a one-to-one mapping with actionID. |
14 -- | 12 -- |
15 -- ReAction makes use of a configuration structure, which can (and should) be | 13 -- ReAction makes use of a configuration structure, which can (and should) be |
75 UpdateDisplay = "function", -- UpdateDisplay(), general display state should be refreshed | 73 UpdateDisplay = "function", -- UpdateDisplay(), general display state should be refreshed |
76 TempShow = "function", -- TempShow(visible), calls to this can be nested so keep track. | 74 TempShow = "function", -- TempShow(visible), calls to this can be nested so keep track. |
77 GetActionFrame = "function", -- f = GetActionFrame(), return a frame derived from SecureActionButtonTemplate (note: this is inherited unimplemented from ReBar.IButton) | 75 GetActionFrame = "function", -- f = GetActionFrame(), return a frame derived from SecureActionButtonTemplate (note: this is inherited unimplemented from ReBar.IButton) |
78 GetBaseButtonSize = "function", -- sz = GetBaseButtonSize(), return size in pixels of the nominal button (square) | 76 GetBaseButtonSize = "function", -- sz = GetBaseButtonSize(), return size in pixels of the nominal button (square) |
79 DisplayID = "function", -- DisplayID(show), true/false to show/hide the action ID (or equivalent) | 77 DisplayID = "function", -- DisplayID(show), true/false to show/hide the action ID (or equivalent) |
80 DisplayHotkey = "function", -- DisplayHotkey(keyText), set the hotkey display text | 78 DisplayHotkey = "function", -- DisplayHotkey(keyText, button), set the hotkey display text. 2nd argument specifies which button the hotkey is for, default is "LeftButton". |
81 } | 79 } |
82 | 80 |
83 | 81 |
84 ---------------------------- | 82 ---------------------------- |
85 -- ReAction class definition | 83 -- ReAction class definition |
290 end | 288 end |
291 | 289 |
292 -- Event handlers | 290 -- Event handlers |
293 | 291 |
294 function ReAction.prototype:UPDATE_BINDINGS() | 292 function ReAction.prototype:UPDATE_BINDINGS() |
295 self:DisplayHotkey(self:GetKeyBindingText(nil, true)) | 293 self:DisplayHotkey(self:GetKeyBindingText("LeftButton", true),"LeftButton") |
294 self:DisplayHotkey(self:GetKeyBindingText("RightButton",true),"RightButton") | |
296 end | 295 end |
297 | 296 |
298 | 297 |
299 -- Internal functions | 298 -- Internal functions |
300 | 299 |
301 function ReAction.prototype:Recycle() | 300 function ReAction.prototype:Recycle() |
302 --self:SetKeyBinding(nil) -- TODO: only if we're using override bindings | |
303 self:UnregisterAllEvents() | 301 self:UnregisterAllEvents() |
304 | 302 |
305 -- tuck the frame away | 303 -- tuck the frame away |
306 local b = self:GetActionFrame() | 304 local b = self:GetActionFrame() |
307 b:SetParent(ReAction.recycler) | 305 b:SetParent(ReAction.recycler) |
327 end | 325 end |
328 | 326 |
329 function ReAction.prototype:SetKeyBinding( k, mouseBtn ) | 327 function ReAction.prototype:SetKeyBinding( k, mouseBtn ) |
330 if k == nil or kbValidate(k) then | 328 if k == nil or kbValidate(k) then |
331 local current = self:GetKeyBinding(mouseBtn) | 329 local current = self:GetKeyBinding(mouseBtn) |
332 -- !!!TODO: do we need this? | |
333 -- ClearOverrideBindings(self:GetActionFrame()) | |
334 if current then | 330 if current then |
335 SetBinding(current,nil) | 331 SetBinding(current,nil) |
336 end | 332 end |
337 if k then | 333 if k then |
338 -- TODO: use OverrideBinding and store the keybinding in the profile. | |
339 SetBindingClick(k, self:GetActionFrame():GetName(), mouseBtn or "LeftButton") | 334 SetBindingClick(k, self:GetActionFrame():GetName(), mouseBtn or "LeftButton") |
340 end | 335 end |
341 end | 336 end |
342 end | 337 end |
343 | 338 |