Go to: Synopsis. Return value. Flags. Python examples.
draggerContext(
[name]
, [anchorPoint=[float, float, float]], [button=int], [currentStep=int], [cursor=string], [dragCommand=script], [dragPoint=[float, float, float]], [drawString=string], [exists=boolean], [finalize=script], [helpString=string], [history=boolean], [holdCommand=script], [image1=string], [image2=string], [image3=string], [initialize=script], [modifier=string], [name=string], [plane=[float, float, float]], [prePressCommand=script], [pressCommand=script], [projection=string], [releaseCommand=script], [snapping=boolean], [space=string], [stepsCount=int], [undoMode=string])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
draggerContext is undoable, queryable, and editable.
The draggerContext allows the user to program the behavior of the mouse
or an equivalent dragging device in MEL.
string | The name of the context. |
In query mode, return type is based on queried flag.
anchorPoint, button, currentStep, cursor, dragCommand, dragPoint, drawString, exists, finalize, helpString, history, holdCommand, image1, image2, image3, initialize, modifier, name, plane, prePressCommand, pressCommand, projection, releaseCommand, snapping, space, stepsCount, undoMode
Long name (short name) |
Argument types |
Properties |
|
anchorPoint(ap)
|
[float, float, float]
|
|
|
Anchor point (double array) where dragger was initially pressed.
|
|
button(bu)
|
int
|
|
|
Returns the current mouse button (1,2,3).
|
|
currentStep(cs)
|
int
|
|
|
Current step (press-drag-release sequence) for dragger context.
When queried before first press event happened, returns 0.
|
|
cursor(cur)
|
string
|
|
|
Cursor displayed while context is active. Valid values are:
"default", "hand", "crossHair", "dolly", "track", and "tumble".
|
|
dragCommand(dc)
|
script
|
|
|
Command called when mouse dragger is dragged.
|
|
dragPoint(dp)
|
[float, float, float]
|
|
|
Drag point (double array) current position of dragger during drag.
|
|
drawString(ds)
|
string
|
|
|
A string to be drawn at the current position of the pointer.
|
|
exists(ex)
|
boolean
|
|
|
Returns true or false depending upon whether the
specified object exists. Other flags are ignored.
|
|
finalize(fnz)
|
script
|
|
|
Command called when the tool is exited.
|
|
helpString(hs)
|
string
|
|
|
history(ch)
|
boolean
|
|
|
If this is a tool command, turn the construction history on
for the tool in question.
|
|
holdCommand(hc)
|
script
|
|
|
Command called when mouse dragger is held.
|
|
image1(i1)
|
string
|
|
|
First of three possible icons representing the tool
associated with the context.
|
|
image2(i2)
|
string
|
|
|
Second of three possible icons representing the tool
associated with the context.
|
|
image3(i3)
|
string
|
|
|
Third of three possible icons representing the tool
associated with the context.
|
|
initialize(inz)
|
script
|
|
|
Command called when the tool is entered.
|
|
modifier(mo)
|
string
|
|
|
Returns the current modifier type: ctrl, alt or none.
|
|
name(n)
|
string
|
|
|
If this is a tool command, name the tool appropriately.
|
|
plane(pl)
|
[float, float, float]
|
|
|
Provide normal of projection plane (see -projection flag for details).
|
|
prePressCommand(ppc)
|
script
|
|
|
Command called when mouse dragger is pressed. It is called before
pressCommand, so it can be used for initialization of context.
|
|
pressCommand(pc)
|
script
|
|
|
Command called when mouse dragger is pressed.
|
|
projection(pr)
|
string
|
|
|
Sets current projection of drag point. Valid types are:
viewPlane |
project to view plane |
objectViewPlane |
project to object plane (parallel to view plane) |
objectPlane |
project to specified plane defined by object location and normal (default) 0,1,0 |
plane |
project to specified plane defined by origin and normal (default) 0,1,0 |
sketchPlane |
project to sketch plane |
xAxis |
project to closest point on X axis |
yAxis |
project to closest point on Y axis |
zAxis |
project to closest point on Z axis |
boundingSphere |
project to closest point on object sphere bounds |
boundingBox |
project to closest point on object bounding box |
|
|
releaseCommand(rc)
|
script
|
|
|
Command called when mouse dragger is released.
|
|
snapping(snp)
|
boolean
|
|
|
Enable/disable snapping for dragger context.
|
|
space(sp)
|
string
|
|
|
Sets current space that coordinates are reported in. Types are:
world |
world space (global) |
object |
object space (local) |
screen |
screen space |
|
|
stepsCount(sc)
|
int
|
|
|
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)
|
string
|
|
|
Undo queue mode for the context actions.
Acceptable values are:
- "all" default 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 "step" for a single step dragger context.
|
|
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can have multiple arguments, passed either as a tuple or a list.
|
import maya.cmds as cmds
# Procedure called on press
def SampleContextPress():
pressPosition = cmds.draggerContext( 'sampleContext', query=True, anchorPoint=True)
print ("Press: " + str(pressPosition))
# Procedure called on drag
def SampleContextDrag():
dragPosition = cmds.draggerContext( 'sampleContext', query=True, dragPoint=True)
button = cmds.draggerContext( 'sampleContext', query=True, button=True)
modifier = cmds.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])
cmds.draggerContext( 'sampleContext', edit=True, drawString=message)
# Define draggerContext with press and drag procedures
cmds.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
cmds.setToolTo('sampleContext')