When you rmb click the screen maya calls buildObjectMenuItemsNow (turn echo all on and rmb), thet command is defined in mayadir/scripts/others/buildObjectMenuItemsNow.mel (whatIs buildObjectMenuItemsNow ), And the answer to your question is in that file it reads in shorttened form:
CODE
...
string $leadObject[] = ls -sl -tail 1 -typ transform -typ shape
;
if (size($leadObject) > 0) {
dagMenuProc($parentName, $leadObject[0]);
}
...
Where parent name is the name of the mm. And dagMenuProc is described in mayadir/others/dagMenuProc.mel go read it. Its a bit long but quite easily followable.
PS what you search for is the last proc in the file you need to jump a bit back and forth to find the relevent parts because it quit oon callsoptionalDagMenuProc wich builds some of the specificts but.