View Single Post
08-29-20, 03:57 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
I tested the code you provided and all three buttons work for me. The left and right buttons even work in combat, but the middle button does not. I used a piece of a weakaura I have for the button.

Lua Code:
  1. local proPlugin=CreateFrame("Button","proPlugin",UIParent,"ActionButtonTemplate,SecureActionButtonTemplate")
  2. proPlugin:SetSize(32,32)
  3. proPlugin.icon:SetTexture(135912)
  4. proPlugin:SetPoint("CENTER")
  5. proPlugin:EnableMouse(true)
  6. proPlugin:SetScript("OnMouseDown",function(self, button)
  7.     local prof1, prof2, _, _, _ = GetProfessions()
  8.     if button == "LeftButton" then
  9.         if prof1 then  
  10.             CastSpellByName((GetProfessionInfo(prof1)))
  11.         else
  12.             print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
  13.         end
  14.     elseif button == 'MiddleButton' then
  15.         ToggleSpellBook(BOOKTYPE_PROFESSION)   
  16.     elseif button == "RightButton" then
  17.         if prof2 then
  18.             CastSpellByName((GetProfessionInfo(prof2)))
  19.         else
  20.             print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
  21.         end
  22.     end
  23. end)
  Reply With Quote