Quantcast
WoWInterface - View Single Post - Right mouse button clicks on menu buttons
View Single Post
06-14-15, 12:42 PM   #1
Niatue
A Defias Bandit
Join Date: Jun 2015
Posts: 3
Right mouse button clicks on menu buttons

Hello, I have an EasyMenu DropDownMenu and I want to be able to both right and left click on the buttons and handle each button click differently. However, right button clicks are not registered at all and there's no way to even tell the left button has been clicked.

My code is:
Code:
local menuFrame = CreateFrame("Frame", "MenuFrame", DropDownButton, "UIDropDownMenuTemplate")

local menuList = {	
	{ text = "Menu 1", hasArrow = true, notCheckable = true,
        menuList = {
            { text = "First option", notCheckable = true, 
		func = function() print("1st option clicked") end },
			
	    { text = "Second option", notCheckable = true, 
		func = function() print("2nd option clicked") end }
        } 
    }
}

local function ShowMenu(self, button)
	EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU")
end

local button = CreateFrame("Button", "DropDownButton", UIParent, "UIPanelButtonTemplate")
button:SetSize(100, 50) 
button:SetText("Menu")
button:SetPoint("CENTER")
button:RegisterForClicks("RightButtonDown", "LeftButtonDown")
button:SetScript("OnClick", ShowMenu)
button:Show()

Is there any way to register both buttons and distinguish between the two via one of the 2 custom arguments menuList takes? Other than having to implement my own DropDownMenu. Is there perhaps a function than can be hooked to "force" it to recognize both buttons?

I'd like to do something like this:

Code:
local menuList = {	
     { text = "Menu 1", hasArrow = true, notCheckable = true,
        menuList = {
          { text = "First option", arg1 = "1st option clicked", arg2 = button, 
	     notCheckable = true, func = function() 
	        if button == "RightButton" then
		     print(arg1)
		else
		     print("Left button clicked!")
		end 
	   end},			
          } 
     }
}
  Reply With Quote