pymel.core.context.draggerContext

draggerContext(*args, **kwargs)

The draggerContext allows the user to program the behavior of the mouse or an equivalent dragging device in MEL.

Flags:
Long name (short name) Argument Types Properties
anchorPoint (ap) float, float, float ../../../_images/query.gif
 
Anchor point (double array) where dragger was initially pressed.
button (bu) int ../../../_images/query.gif
 
Returns the current mouse button (1,2,3).
currentStep (cs) int ../../../_images/query.gif
 

Current step (press-drag-release sequence) for dragger context. When queried before first press event happened, returns 0. Flag can have multiple arguments, passed either as a tuple or a list.

cursor (cur) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Cursor displayed while context is active. Valid values are: default, hand, crossHair, dolly, track, and tumble.
dragCommand (dc) callable ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Command called when mouse dragger is dragged.
dragPoint (dp) float, float, float ../../../_images/query.gif
 
Drag point (double array) current position of dragger during drag.
drawString (ds) unicode ../../../_images/create.gif ../../../_images/edit.gif
 
A string to be drawn at the current position of the pointer.
exists (ex) bool ../../../_images/create.gif
 
Returns true or false depending upon whether the specified object exists. Other flags are ignored.
finalize (fnz) callable ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Command called when the tool is exited.
helpString (hs) unicode  
   
history (ch) bool ../../../_images/create.gif
 
If this is a tool command, turn the construction history on for the tool in question.
holdCommand (hc) callable ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Command called when mouse dragger is held.
image1 (i1) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
   
image2 (i2) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
   
image3 (i3) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Contexts support up to three icons that represent the tool associated with the context.
initialize (inz) callable ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Command called when the tool is entered.
modifier (mo) unicode ../../../_images/query.gif
 
Returns the current modifier type: ctrl, alt or none.
name (n) unicode ../../../_images/create.gif
 
If this is a tool command, name the tool appropriately.
plane (pl) float, float, float ../../../_images/create.gif ../../../_images/edit.gif
 
Provide normal of projection plane (see -projection flag for details).
prePressCommand (ppc) callable ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Command called when mouse dragger is pressed. It is called before pressCommand, so it can be used for initialization of context.
pressCommand (pc) callable ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Command called when mouse dragger is pressed.
projection (pr) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

Sets current projection of drag point. Valid types are: viewPlaneproject to view planeobjectViewPlaneproject to object plane (parallel to view plane)objectPlaneproject to specified plane defined by object location and normal (default) 0,1,0planeproject to specified plane defined by origin and normal (default) 0,1,0sketchPlaneproject to sketch planexAxisproject to closest point on X axisyAxisproject to closest point on Y axiszAxisproject to closest point on Z axisboundingSphereproject to closest point on object sphere boundsboundingBoxproject to closest point on object bounding box

releaseCommand (rc) callable ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Command called when mouse dragger is released.
snapping (snp) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Enable/disable snapping for dragger context.
space (sp) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Sets current space that coordinates are reported in. Types are: worldworld space (global)objectobject space (local)screenscreen space
stepsCount (sc) int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Number of steps (press-drag-release sequences) for dragger context. When combined with undoMode flag, several steps might be recorded as single undo action.
undoMode (um) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

Undo queue mode for the context actions. Acceptable values are: alldefault behaviour when every action that happens during dragger context activity is recorded as an individual undo chunk.step- all the actions that happen between each press and release are combined into one undo chunk.sequence- all the actions that happen between very first press and very last release are combined into single undo chunk. This works exactly the same as stepfor a single step dragger context.

Derived from mel command maya.cmds.draggerContext

Example:

import pymel.core as pm

# Procedure called on press
def SampleContextPress():
    pressPosition = pm.draggerContext( 'sampleContext', query=True, anchorPoint=True)
    print ("Press: " + str(pressPosition))

# Procedure called on drag
def SampleContextDrag():
    dragPosition = pm.draggerContext( 'sampleContext', query=True, dragPoint=True)
    button = pm.draggerContext( 'sampleContext', query=True, button=True)
    modifier = pm.draggerContext( 'sampleContext', query=True, modifier=True)
    print ("Drag: " + str(dragPosition) + "  Button is " + str(button) + "  Modifier is " + modifier + "\n")
    message = str(dragPosition[0]) + ", " + str(dragPosition[1])
    pm.draggerContext( 'sampleContext', edit=True, drawString=message)

# Define draggerContext with press and drag procedures
pm.draggerContext( 'sampleContext', pressCommand='SampleContextPress()', dragCommand='SampleContextDrag()', cursor='hand' );

# Set the tool to the sample context created
# Results can be observed by dragging mouse around main window
pm.setToolTo('sampleContext')

Previous topic

pymel.core.context.dragAttrContext

Next topic

pymel.core.context.drawExtrudeFacetCtx

Core

Core Modules

Other Modules

This Page