Originally Posted by Lazare69
I simply want a simple "press this button and world marker blue is on your cursor to place it." The same with green, purple and red (separate buttons and scripts for each).
|
Placing world markers is a secure action, so you need a secure button:
Code:
local blue = CreateFrame("Button", "MyBlueWMButton", UIParent, "SecureActionButtonTemplate")
-- Set blue world marker on left-click:
blue:SetAttribute("type1", "worldmarker")
blue:SetAttribute("marker1", 1)
blue:SetAttribute("action1", "set")
-- Clear blue world marker on right-click:
blue:SetAttribute("type2", "worldmarker")
blue:SetAttribute("marker2", 1)
blue:SetAttribute("action2", "clear")
The above won't give you a visible button. If you want a visible button, you need to anchor and size the button, and add a texture/fontstring/etc.
To bind keys to "left-click" or "right-click" the button:
Code:
SetBinding("SHIFT-U", "CLICK MyBlueWMButton:LeftButton")
SetBinding("ALT-SHIFT-U", "CLICK MyBlueWMButton:RightButton")
To add entries to the key binding UI, add a Bindings.xml file to your addon:
Code:
<Bindings>
<Binding name="CLICK MyBlueWMButton:LeftButton" header="MYWORLDMARKERS">
-- Set blue marker
</Binding>
<Binding name="CLICK MyBlueWMButton:RightButton">
-- Clear blue marker
</Binding>
...and define the UI strings in Lua:
Code:
_G["BINDING_HEADER_MYWORLDMARKERS"] = "My World Markers"
_G["BINDING_NAME_CLICK MyBlueWMButton:LeftButton"] = "Set Blue Marker"
_G["BINDING_NAME_CLICK MyBlueWMButton:RightButton"] = "Clear Blue Marker"
See also
FlareUP, which provides clickable and bindable buttons for all the world markers and some other features, and was the main source of the above example code snippets.