Thread Tools Display Modes
09-15-12, 04:01 PM   #1
jostor
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 10
OnClick only registering for the left mouse button?

Hey! I dislike the new 5.0 "feature" that changed the minimap button in battlegrounds which you use to show the scoreboard, and right click to for example leave the BG or interact with your queue to other BGs and so on. It no longer simply shows the scoreboard with a left click, it has an annoying menu with the scoreboard button way too close to the "Leave Battleground" button, and what I wanted to do was simply change it so that with the left mouse button you open the scoreboard, but with the right mouse button you open the regular menu as you normally would. For LFG instances (which now uses the same button) it should open the menu regardless of which button was used.

The first part was easy, getting the scoreboard to open with the left button, that part is working fine. However, the right mouse button simply does nothing, since my OnClick function doesn't have any code for it, but is there a simple way to make it work like it normally would, either by simply adding it into my if-clause, or having OnClick only registering the left mouse button.

Here's my code:

Lua Code:
  1. local frameCurrentlyShown = false
  2. QueueStatusMinimapButton:SetScript("OnClick", function(self, button)
  3.     isInstance, instanceType = IsInInstance()
  4.        
  5.     if isInstance and instanceType == "pvp" and button == "LeftButton" then
  6.         if frameCurrentlyShown then
  7.             WorldStateScoreFrame:Hide()
  8.             frameCurrentlyShown = false
  9.         else
  10.             WorldStateScoreFrame:Show()
  11.             frameCurrentlyShown = true
  12.         end
  13.     else
  14.         -- Show the regular menu
  15.     end
  16.  
  17. end)

Simply running DropDownList1:Show() (DropDownList1 is the name of the regular frame that pops up...) doesn't work, I assume since the frame also has to be filled with information.
  Reply With Quote
09-15-12, 04:23 PM   #2
Maggz
A Cyclonian
 
Maggz's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 45
just seems your handling the if statements and button definaitions improperly here is a small example and it probably wont work as ive not tested anything about it but here goes

Lua Code:
  1. local frameCurrentlyShown = false
  2. QueueStatusMinimapButton:SetScript("OnClick", function(self, button)
  3.     isInstance, instanceType = IsInInstance()
  4.     if isInstance and instanceType == "pvp"
  5.         if button == "LeftButton" then
  6.             if frameCurrentlyShown then
  7.                 DOSTUFF1() -- used to click if instance type is PVP and its frame is shown (left click)
  8.             else
  9.                 DOSOMTHING1() -- used to click if instance is PVP and its frame isnt shown (left click)
  10.             end
  11.         else
  12.             DOSOMETHING2() -- used to click if instance is PVP and frame shown isnt an issue and function was a right click.
  13.         end
  14.     end
  15. end)

you could even define the last section further for other arguments and obtain a right and left click button function if your also not on PVP.

having too many arguements in one line like you had tends to be a bit of an issue, again i havent tried any of your code i just put it into a text editor and tried to do something that made sense to me. I am sure others have other ideas that may work even cleaner.
__________________
Maggz Turalyon-US

Last edited by Maggz : 09-15-12 at 04:30 PM.
  Reply With Quote
09-15-12, 06:50 PM   #3
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Code:
local QueueStatusMinimapButton_OnClick_orig = QueueStatusMinimapButton_OnClick
QueueStatusMinimapButton_OnClick = function(...)
  local _, instanceType = IsInInstance()
  local _, button = ...
  if instanceType == "pvp" and button == "LeftButton" then
    local shown = WorldStateScoreFrame:IsVisible() and WorldStateScoreFrame:Hide() or WorldStateScoreFrame:Show()
  else
    QueueStatusMinimapButton_OnClick_orig(...)
  end
end
Warning: drycoded

Alternative version of the same thing in case the button is using 'new style' <OnShow function='blah'/> handler.
Code:
local QueueStatusMinimapButton_OnClick_orig = QueueStatusMinimapButton:GetScript("OnClick")
QueueStatusMinimapButton:SetScript("OnClick", function(...)
  local _, instanceType = IsInInstance()
  local _, button = ...
  if instanceType == "pvp" and button == "LeftButton" then
    local shown = WorldStateScoreFrame:IsVisible() and WorldStateScoreFrame:Hide() or WorldStateScoreFrame:Show()
  else
    QueueStatusMinimapButton_OnClick_orig(...)
  end
end)

Last edited by Dridzt : 09-15-12 at 07:05 PM.
  Reply With Quote
09-15-12, 09:45 PM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
:RegisterForClicks('LeftButton', 'RightButton')

Last edited by p3lim : 09-15-12 at 10:14 PM.
  Reply With Quote
09-15-12, 10:03 PM   #5
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Code:
function QueueStatusMinimapButton_OnLoad(self)
	self:RegisterForClicks("LeftButtonUp", "RightButtonUp");
	self:SetFrameLevel(self:GetFrameLevel() + 1);
end
It's already registered for Left|Right, don't think that was his problem despite the misleading title.
  Reply With Quote
09-16-12, 02:30 AM   #6
jostor
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 10
Originally Posted by Dridzt View Post
Code:
local QueueStatusMinimapButton_OnClick_orig = QueueStatusMinimapButton_OnClick
QueueStatusMinimapButton_OnClick = function(...)
  local _, instanceType = IsInInstance()
  local _, button = ...
  if instanceType == "pvp" and button == "LeftButton" then
    local shown = WorldStateScoreFrame:IsVisible() and WorldStateScoreFrame:Hide() or WorldStateScoreFrame:Show()
  else
    QueueStatusMinimapButton_OnClick_orig(...)
  end
end
Warning: drycoded

Alternative version of the same thing in case the button is using 'new style' <OnShow function='blah'/> handler.
Code:
local QueueStatusMinimapButton_OnClick_orig = QueueStatusMinimapButton:GetScript("OnClick")
QueueStatusMinimapButton:SetScript("OnClick", function(...)
  local _, instanceType = IsInInstance()
  local _, button = ...
  if instanceType == "pvp" and button == "LeftButton" then
    local shown = WorldStateScoreFrame:IsVisible() and WorldStateScoreFrame:Hide() or WorldStateScoreFrame:Show()
  else
    QueueStatusMinimapButton_OnClick_orig(...)
  end
end)
Thank you, saving the original function was the part I was missing.

Final code (seems to be working fine as far as my testing goes):
Lua Code:
  1. local QueueStatusMinimapButton_OnClick_orig = QueueStatusMinimapButton:GetScript("OnClick")
  2. QueueStatusMinimapButton:SetScript("OnClick", function(...)
  3.     local isInstance, instanceType = IsInInstance()
  4.     local _, button = ...
  5.        
  6.     if isInstance and instanceType == "pvp" and button == "LeftButton" then
  7.         if WorldStateScoreFrame:IsVisible() then
  8.             WorldStateScoreFrame:Hide()
  9.         else
  10.             WorldStateScoreFrame:Show()
  11.         end
  12.     else
  13.         QueueStatusMinimapButton_OnClick_orig(...)
  14.     end
  15.  
  16. end)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » OnClick only registering for the left mouse button?


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