Try using
SecureUnitButtonTemplate. Your frame needs to be of type
Button like this.
Code:
<Button name="SUF_PlayerFrame" parent="UIParent" inherits="SecureUnitButtonTemplate" movable="true">
In your OnLoad script, you need to add these. (Note: You should pass
self to your OnLoad handler and use that.)
Code:
self:RegisterForClicks("AnyUp");
self:SetAttribute("unit","player");
self:SetAttribute("type1","target");
self:SetAttribute("type2","togglemenu");
This sets up the necessary attributes to mimic what the default PlayerFrame does.