Notifications
Clear all

[Closed] Right click event handler?

Hi,
please don’t feel annoyed, I know this is a recurring question, but I’d like to know if anything has changed with new scriptng options available through, in example, dotNet.

Is it possible to define an event handler to detect right mouse button click? I don’t mean a check on every defined time interval, which adds overhead, just an event handler. Right next to this question, is it possible to stop the quad menu from popping up when that event is detected?

The background: I’m thinking up to develop a better Draw tool for IC. Something like a three steps cut. The first draws the cutting line/points to connect, then they can be adjusted, like moved on faces, slid along edges, snapped to vertices. A right click then makes the real cut.
Working with “thePainterInterface” API, I need to detect the right click and prevent the quads popup.

Thank you

  • Enrico
9 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

mouseTrack() Function is the solution in your case. MouseTrack was designed exactly for your type of tasks. With mouse track callback you will capture left and right mouse button states. Also MouseTrack blocks any right-click events (popup quad menu or context menu) in viewports.

can’t detect right-click with .NET as the .NET bridge can’t handle what’s involved there, apparently:
http://forums.cgsociety.org/showthread.php?f=98&t=574756&highlight=mouse+event

can’t detect right-click with MXS because mouse.buttonStates’ handling of right-clicks is broken – that is to say, it never reports when the right mouse button is no longer depressed.

and there’s no clean way to detect the quad menu popping up, it seems (not through an existing event, not through dialogMonitor ops – timered might still work , but you mentioned that to be a no-no.

good luck :\

I’m not sure what you mean by a ‘Draw tool for IC’ but base on the reset of your post regarding cut, I’d say have a look into scripted mouse tools if you haven’t already.

Thank you guys,
I understand it’s a daunting task. I’ll try to figure out something different, or wait until my C++ knowledge grows enough to start coding something smarter with the SDK, even though I can’t see how to replace the robust PainterInterface.

Joel, Draw Tool is part of IllusionCatalyst a set of free instruments I developed to make modeling, facial rigging and keyframing more enjoyable.

  • Enrico

Sorry to renew this old thread, but the question is timeless. Is there ANY way to detect a right click in viewports? I mean ANYthing that comes to mind: timers, rollout – dialogs tricks, windows – DialogMonitorOPS – UIAccessor voodoo, DotNet, Python, Echelon, Arpanet, Spy Satellites, CERN LHC… ?

  • Enrico

Hi Denis,
I’ve been using mouseTrack() all the time, and it does the job (see IC.PolySplitRing). I prefer thePainterInterface by far, but it cannot detect right click, its only real big issue. (Actually it can, but it’s not exposed to MaxScript 🙁 )

So, what’s wrong with mouseTrack()? It works on meshes ONLY. If you want to make it work on editable mesh, you got to make snapshot, hide it, delete it after the job is done. Quite clean, unless you want to undo more than once or a couple of times. If you’re lucky, and can do that, you’ll end up with a corrupted editable poly, one ore more forgotten hidden meshes and the undo stack flushed.

Since I’m rewriting IC.Shape, and want to stay with thePainterInterface for all tracking tools, I was wondering if there is, anything to detect the right click I crave for. Well, I could code something in C++, but that would spoil the meaning of doing it all in MaxScript (read painless portability). If anything comes to mind, you win my eternal gratitude

  • Enrico

on:<node> MouseTrack feature works for editable_meshes only because it uses IntersectRay() (which really works only for editable meshes). But you can not use on node thing, and calculate intersection ray yourself. You have a node, you have a ray, use RayMeshGridIntersect interface to get any hit info (face, bary, normal, distance, etc.). It works for any geometry class.

It’s not a problem to catch mouse right-click. The problem is how to block popping up quad and context menus.

If no one else has anything to say… we have a winner!

Just fiddled with your idea of doped mouseTrack(), it works! I still got to run extensive tests and see how RayMeshGridIntersect behaves in various situations, like when part of the geometry is hidden, the undo case, and so on… but hey, it works! Still have to figure out what are best adaptive settings for the voxel grid relative to object dimensions, but it is a minor issue.

Thank you very much!

p.s.
I must update the article “Editable Poly data from underlying Mesh”. This is a way better solution, no more hidden mesh monsters!

Default settings for RayMeshGridIntersect work well. I played with them and couldn’t find any reason to change anything.
2.
There are two things that you have to know. RayMeshGridIntersect detects intersection with hidden faces and hidden nodes. I’m using intersectRayScene first to filter hidden geometry and sort nodes by distance.
3.
RayMeshGridIntersect doesn’t interfere with undo/redo