For the right-click on pet action, you can use macro type for the right-click. Well, no harm to click the original pet action button.
Lua Code:
self:SetAttribute("type2", "macro")
self:SetAttribute("macrotext2", "/click PetActionButton".. target .. " RightButton")
It's a little difficult to figure out the action page, I use three steps to figure it out:
1. Use SetFrameRef to register the
MainMenuBarArtFrame and
OverrideActionBar to your secure frame, so we can get some action page securely during combat:
ActionHandler.lua#L147-L148
2. Register state for conditions like stance
ActionHandler.lua#L151-L188
3. At last, the secure snippet to get the real action page based on the state and the MainMenuBarArtFrame or OverrideActionBar
ActionHandler.lua#L94-L117