View Full Version : Popup menu in a custom context
Andimation 04-12-2009, 02:58 PM Hi
I'm writing a custom selection context using MPxContext. I want to implement an object pick chooser pop-up menu similar to the one in Maya's selection tool (Can be turned on in the selection preferences). Like the one built-in, I want it to be triggered by the left mouse button. So when I click it runs my onPress function and then pops up a menu based on the result.
I have been trying to use a popup menu for this, but it won't work because the popup is being triggered first, and so my onpress function does not get executed. The only way I can think of is to draw my own menu in openGL/glut. I don't have much experience with either. So I don't know whether this is a viable option. Any thoughts?
Thanks
|
|
strarup
04-12-2009, 10:30 PM
Hi Andy,
don't know if this is useful... however will suggest you to take a look at this post "adding items to an objects RMB menu (http://forums.cgsociety.org/showthread.php?f=88&t=143632)" by macaroniKazoo... :)
kind regards
Strarup
claydough
04-12-2009, 10:45 PM
did you try your function in popUpMenu's -postMenuCommand?
"dagObjectHit"isn't in the mel command documentation however you can find all the flags for it in quick help.
additionally ls -preSelectHilite
is helpful for contextual component cursor query
a template fer both:
// cly_contextualCursorHit_template.mel
//__________________________________________________ ______________________________________
{
if( `popupMenu -exists cly_contextualTrash` ) {
deleteUI cly_contextualTrash;
}
popupMenu
-alt 1
-button 3
-mm 1
-p viewPanes
-pmc ( "string $bob[] = `ls -preSelectHilite`;"+ // ls return of pre-select hilite under cursor
"if (`popupMenu -e -exists cly_contextualTrash`) {"+
"popupMenu -e -deleteAllItems cly_contextualTrash;"+
" setParent -menu cly_contextualTrash;"+
"if ( `dagObjectHit`)"+ // dag object Hit returns int if cursor is over an object
"menuItem -label \"object under cursor\";"+
"else"+
" menuItem -label \"no object under cursor\";"+
"if ( size( $bob ) ) "+
" for ( $b in $bob ) "+
"menuItem"+
"-label $b; }" )
cly_contextualTrash;
}
//__________________________________________________ ______________________________________
// end
after executing the above code:
alt + rightclick on object and components
builds dynamic popUp that reflects object and component status under cursor
http://farm4.static.flickr.com/3312/3306012217_9017df23af_o.jpg
http://forums.cgsociety.org/showthread.php?t=732141
Andimation
04-14-2009, 03:33 PM
Thanks for the replies.
Alex - Yes I know about the dagMenuProc techinique, but that's not what I am after.
Claydough - I had not heard of the dagObjectHit command before. I think that could become useful for part of my context. That's strange that it has never been documented.
I think I can hack something together by putting the content of my onPress function in the context into a command. Then defining the popmenu instead, and use the postMenuCommand to execute my command. The only downside being that I want the popup menu conditionally driven only if there is more than one object to select. Plus I don't need to handle components.
Its given me a few ideas. So thanks.
CGTalk Moderation
04-14-2009, 03:33 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.