Code Red > .NET
How to catch mouse click events.
(1/1)
kh001058:
Hi everybody,
I'm trying to mimic the PAN command, to begin, it must be catch the mouse click events, I think.
Is there anyway to detect the mouse click event in AutoCAD.NET : mouse_down, mouse_move, mouse_up ...
Any help regarding this issue will be appreciated.
Regards.
Jeff H:
I had to monitor mouse events inside of Editor.CommandAsync/Editor.Command and used Autodesk.AutoCAD.ApplicationServices.Core.Application.PreTranslateMessage Event
--- Code - C#: --- private const int MK_SHIFT = 4; private const int WM_RBUTTONUP = 517; private const int WM_LBUTTONUP = 514; private const int WM_LBUTTONDOWN = 513; private const int WM_RBUTTONDOWN = 516; private void Application_PreTranslateMessage(object sender, PreTranslateMessageEventArgs e) { var wp = e.Message.wParam.ToInt64(); if (e.Message.message == WM_RBUTTONDOWN && (wp != 6 && wp != MK_SHIFT)) { e.Handled = true; } if (e.Message.message == WM_RBUTTONUP && wp != MK_SHIFT) { Application.PreTranslateMessage -= Application_PreTranslateMessage; e.Handled = true; Application.DocumentManager.MdiActiveDocument.SendCancel(); } }
Not much info in acad docs so this might help
https://docs.microsoft.com/en-us/windows/win32/learnwin32/mouse-clicks
https://docs.microsoft.com/en-us/windows/win32/inputdev/mouse-input-notifications
Navigation
[0] Message Index
Go to full version