API

These docs use [[Autodoc_Format|Autodoc]] for the [[LibKeyBound-1.0/API#API_Documentation|LibKeyBound API Documentation]] at the bottom.

Links

  • Old Ace working docs: API

Functions you need to implement on your Button

Required

	button:GetHotkey() - returns the current hotkey assigned to the given button

For a custom keybindings system

	button:SetKey(key) - binds the given key to the given button
	button:FreeKey(key) - unbinds the given key from all other buttons
	button:ClearBindings() - removes all keys bound to the given button
	button:GetBindings() - returns a string listing all bindings of the given button
	button:GetActionName() - what we're binding to, used for printing

What your Mod has to do

Include the Library

MyMod/libs svn:externals property:

LibStub http://svn.wowace.com/wowace/tags/LibStub/1.0/
...
LibKeyBound-1.0 http://svn.wowace.com/wowace/trunk/LibKeyBound-1.0/LibKeyBound-1.0/
...

embeds.xml:

<Script file="libs\LibStub\LibStub.lua"/>
<Script file="libs\CallBackHandler-1.0\CallbackHandler-1.0.lua"/>
<Include file="libs\LibKeyBound-1.0\lib.xml"/>

MyMod.toc

## OptionalDeps: ...LibKeyBound-1.0...
## X-Embeds: ...LibKeyBound-1.0...

Attach the LibKeyBound frame to your button on Mouse Enter

local LibKeyBound = LibStub("LibKeyBound-1.0")
...
	function MyButtonClass:OnEnter()
		local button = this
		if (button.GetHotkey) then
			LibKeyBound:Set(button)
		end
	end

Register and Respond to Events

function MyMod:OnEnable(first)
	...
	LibKeyBound.RegisterCallback(self, "LIBKEYBOUND_ENABLED")
	LibKeyBound.RegisterCallback(self, "LIBKEYBOUND_DISABLED")
	LibKeyBound.RegisterCallback(self, "LIBKEYBOUND_MODE_COLOR_CHANGED")
end
...
function MyMod:ColorMyMod()
	local overlayFrame = MyMod:GetOverlayFrame
	if (MyMod.keyBoundMode) then
		...
		overlayFrame:SetBackdropColor(LibKeyBound:GetColorKeyBoundMode())
	elseif (MyMod.someOtherMode) then
		...
	end
end

function MyMod:LIBKEYBOUND_ENABLED()
	MyMod:OtherModeOff()
	MyMod.keyBoundMode = true
	MyMod:ColorMyMod()
end

function MyMod:LIBKEYBOUND_DISABLED()
	MyMod.keyBoundMode = nil
	MyMod:ColorMyMod()
end

function AutoBar:LIBKEYBOUND_MODE_COLOR_CHANGED()
	AutoBar:ColorMyMod()
end

Activate Key Binding Mode

	LibKeyBound:Activate()

or

	LibKeyBound:Toggle()


{{:API_Docs/LibKeyBound-1.0/LibKeyBound-1.0/LibKeyBound-1.0.lua}}


Comments

Posts Quoted:
Reply
Clear All Quotes