From a5663bdc2f6203cc003ab3a61b044ca2a15236e6 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Fri, 28 Mar 2008 10:45:48 +0000 Subject: [PATCH] * Added a right-click option to clear the current waypoint on the arrow --- TomTom_CrazyArrow.lua | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua index a52834c..eb7cb83 100644 --- a/TomTom_CrazyArrow.lua +++ b/TomTom_CrazyArrow.lua @@ -233,3 +233,58 @@ function TomTom:ShowHideCrazyArrow() end wayframe:SetScript("OnUpdate", OnUpdate) + + +--[[------------------------------------------------------------------------- +-- Dropdown +-------------------------------------------------------------------------]]-- + +local dropdown_info = { + -- Define level one elements here + [1] = { + { -- Title + text = L["TomTom Waypoint Arrow"], + isTitle = 1, + }, + { -- Remove waypoint + text = L["Remove waypoint"], + func = function() + local uid = active_point + TomTom:RemoveWaypoint(uid) + end, + }, + } +} + +local function init_dropdown(level) + -- Make sure level is set to 1, if not supplied + level = level or 1 + + -- Get the current level from the info table + local info = dropdown_info[level] + + -- If a value has been set, try to find it at the current level + if level > 1 and UIDROPDOWNMENU_MENU_VALUE then + if info[UIDROPDOWNMENU_MENU_VALUE] then + info = info[UIDROPDOWNMENU_MENU_VALUE] + end + end + + -- Add the buttons to the menu + for idx,entry in ipairs(info) do + if type(entry.checked) == "function" then + -- Make this button dynamic + local new = {} + for k,v in pairs(entry) do new[k] = v end + new.checked = new.checked() + entry = new + end + UIDropDownMenu_AddButton(entry, level) + end +end + +wayframe:RegisterForClicks("RightButtonUp") +wayframe:SetScript("OnClick", function(self, button) + UIDropDownMenu_Initialize(TomTom.dropdown, init_dropdown) + ToggleDropDownMenu(1, nil, TomTom.dropdown, "cursor", 0, 0) +end) -- 1.7.9.5