Thread Tools Display Modes
08-11-09, 06:58 PM   #1
Cidwel
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 23
Left and Right mouse button to scripting

Hi all!

I have a question, I need a simple snippet to make a button that, if you press with left mouse button, it will do something and if you press right mouse button it will do something else.

I tried a lot of codes like using registerForClicks and trying to use that code in order to get my snippet to work:

Code:
-- Illustrates the timing of mouse script handlers when clicking a button
local b = CreateFrame("Button", "TestButton", UIParent, "UIPanelButtonTemplate2")
b:SetPoint("CENTER")
b:RegisterForClicks("AnyDown")
local upDown = { [false] = "Up", [true] = "Down" }
local function show(text)
  DEFAULT_CHAT_FRAME:AddMessage(text)
end
b:SetScript("OnMouseDown", function(self, button)
  show(format("OnMouseDown: %s", button))
end)
Only I need a code to SendChatMessage something with one mouse button and SendChatMessage something else with the other mouse button but I can't get this >_<

Someone knows a simple snippet to get this working?
  Reply With Quote
08-11-09, 07:13 PM   #2
Katae
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 208
Code:
-- Illustrates the timing of mouse script handlers when clicking a button
local b = CreateFrame("Button", "TestButton", UIParent, "UIPanelButtonTemplate2")
b:SetPoint("CENTER")
b:RegisterForClicks("AnyDown")
b:SetScript("OnMouseUp", function(self, button)
  if button == "LeftButton" then
    print("Left-click")
  elseif button == "RightButton" then
    print("Right-click")
  end
end)

Last edited by Katae : 08-11-09 at 07:16 PM.
  Reply With Quote
08-14-09, 07:28 AM   #3
Scorcher24
A Murloc Raider
Join Date: Aug 2009
Posts: 6
Is it possible to achieve this with a SecureActionButtonTemplate too?
rya.
  Reply With Quote
08-14-09, 08:10 AM   #4
Cidwel
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 23
couldn't use that in something simple like:

Code:
function PIPI_btn_SpamPremade10_OnClick()
      blaaargmouse
end
>_<
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Left and Right mouse button to scripting


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off