Maya mouse movement event, mouse dragging direction ?

491 views
Skip to first unread message

Virbhadra Gupta

unread,
Feb 7, 2018, 3:24:57 PM2/7/18
to Python Programming for Autodesk Maya
hey,
i creating code where we can update value by dragging mouse on maya view port.
i want to get mouse movement (up, down, right or left) or mouse cursor  anchor point.
i can query anchor point with draggerContext commant but it's gives only first point only.
so i am unable to know mouse dragging direction.

please let me know if my approach is right or wrong and how can we get mouse dragging direction.
  

Phil Sloggett

unread,
Feb 7, 2018, 5:32:39 PM2/7/18
to python_in...@googlegroups.com
You can use the dragger context to record mouse movement as long as he mouse click is held down, im pretty sure the docs have an example of exactly this under the dragger context command. If you want to record mouse movement without holding the button down then I think you’ll have to turn to QT...
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/33a07d27-2fa4-4a8d-8529-3b9c1642cdb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Virbhadra Gupta

unread,
Feb 7, 2018, 11:40:25 PM2/7/18
to Python Programming for Autodesk Maya
Here is sample code. It will give first click value and keeps on giving same again so i am unable to know drag direction.

contx = "valueDrag"

def onDrag ():
x = cmds.dragferContext(contx, q=True, ap=True)
print x


if cmds.draggerContext(contx, q=True, ex=True):
cmd.deleteUI(contx)
cmd.draggerContext(contx, dc=onDrag, cur="tumble")
cmds.setToolTo(contx)
____________
Result will be like on mouse drag
All anchor point will come same it give only first point of click.

(2,45,0)
(2,45,0)
(2,45,0)
(2,45,0)

Justin Israel

unread,
Feb 8, 2018, 5:00:33 AM2/8/18
to python_in...@googlegroups.com


On Thu, Feb 8, 2018, 5:40 PM Virbhadra Gupta <viru....@gmail.com> wrote:
Here is sample code. It will give first click value and keeps on giving same again so i am unable to know drag direction.

contx = "valueDrag"

def onDrag ():
    x = cmds.dragferContext(contx, q=True, ap=True)

This is going to query the anchorPoint each time, which is the start point of the drag. You probably ly want to query the dragPoint to get the current position 

x = cmds.draggerContext(contx, q=True, dp=True)

    print x


if cmds.draggerContext(contx, q=True, ex=True):
    cmd.deleteUI(contx)
cmd.draggerContext(contx, dc=onDrag, cur="tumble")
cmds.setToolTo(contx)
____________
Result will be like on mouse drag
All anchor point will come same it give only first point of click.

(2,45,0)
(2,45,0)
(2,45,0)
(2,45,0)

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Virbhadra Gupta

unread,
Feb 8, 2018, 6:01:44 AM2/8/18
to python_in...@googlegroups.com
Thanks i got it.

On Feb 8, 2018 3:30 PM, "Justin Israel" <justin...@gmail.com> wrote:


On Thu, Feb 8, 2018, 5:40 PM Virbhadra Gupta <viru....@gmail.com> wrote:
Here is sample code. It will give first click value and keeps on giving same again so i am unable to know drag direction.

contx = "valueDrag"

def onDrag ():
    x = cmds.dragferContext(contx, q=True, ap=True)

This is going to query the anchorPoint each time, which is the start point of the drag. You probably ly want to query the dragPoint to get the current position 

x = cmds.draggerContext(contx, q=True, dp=True)

    print x


if cmds.draggerContext(contx, q=True, ex=True):
    cmd.deleteUI(contx)
cmd.draggerContext(contx, dc=onDrag, cur="tumble")
cmds.setToolTo(contx)
____________
Result will be like on mouse drag
All anchor point will come same it give only first point of click.

(2,45,0)
(2,45,0)
(2,45,0)
(2,45,0)

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/VThpSpH6Fi0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA05oSTOQdQXL8VPcxWu0rGbYMEqSiEe%2BEyCr0y98CJPzw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages