1. Let's say I have a secure action button.  Is it possible to do something like this:

    button:SetAttribute("type", "spell")

    button:SetAttribute("spell", "Power Word: Fortitude")



    button:SetAttribute("shift-type*", "macro")

    button:SetAttribute("macrotext", "\s Hello!)

    The exact details aren't important, what I'm trying to do it switch the type attribute of the button based on whether shift is held down or not.  So clicking normally will cast a spell but shift clicking will run a macro (in the above example).  There are lots of good examples with switching behaviour based on modifer keys in the book but always within the same type.  Is there any way to do this?  (Note that changing them both to macros is not an option as a macro is just an example of the alternate action that I want to take.)

    Let's say I have a secure action button.  Is it possible to do something like this:

    button:SetAttribute("type", "spell")

    button:SetAttribute("spell", "Power Word: Fortitude")



    button:SetAttribute("shift-type*", "macro")

    button:SetAttribute("macrotext", "\s Hello!)

    The exact details aren't important, what I'm trying to do it switch the type attribute of the button based on whether shift is held down or not.  So clicking normally will cast a spell but shift clicking will run a macro (in the above example).  There are lots of good examples with switching behaviour based on modifer keys in the book but always within the same type.  Is there any way to do this?  (Note that changing them both to macros is not an option as a macro is just an example of the alternate action that I want to take.)

    Yes, this is exactly how the system works.  However, you should avoid using * and the catch-all type and make what you want explicit for a given mouse button:

    button:SetAttribute("type1", "spell")

    button:SetAttribute("spell1", "Power Word: Fortitude")
    button:SetAttribute("shift-type1", "macro")

    button:SetAttribute("shift-macrotext1", "/say Hello!")

    That should give you what I think you'd expect, a button where a unmodified left click casts a spell while a shift-leftclick runs a macro instead.

     

     

    Perfect thanks.  One additional question, the book refers to "function" as a possible value for type.  This is missing from the wowwiki API but I assume it does actually exist!  Are there any restrictions to what function I can call from this due to taint?  Presumably I could use it to recreate the above but with the /say done within a function (using SendChatMessage)?

    Essentially, if the type is set to something that isn't recognized (let's say "message") then you can run a function using the following:

    button:SetAttribute("type1", "message")
    function button.message()
      ChatFrame1:AddMessage("You are a monkey!")
    end
    

    This will cause the button to add "You are a monkey" to the chat frame when the button is clicked.  There are no limitations to what you can do via these functions other than the normal tainting rules.  This is actually how the pop-up menus for unit frames are implemented, via the menu type and function.

    Ahh, I wans't doing it like that, that makes more sense, thanks.

    Working perfectly, thanks.