Page 1 of 1

How to capture Keyboard and Mouse input?

Posted: 02 Feb 2016, 13:11
by clho40
Hello,

I would like to implement Keyboard Shortcut to the drawing. How can I capture the Keyboard input?

also, I would like to disable right mouse click. How can I do that also?

Thanks in advance.

Re: How to capture Keyboard and Mouse input?

Posted: 03 Feb 2016, 09:11
by support
Hello,

You can capture key presses using the following CADViewX events:

AxCADViewX.OnKeyDown
AxCADViewX.OnKeyPress


To disable a pop-up menu (invoked by the right mouse click) you can use AxCADViewX.SelfPopupMenu property as shown below:

Code: Select all

AxCADViewLib.AxCADViewX cadviewx1 = new AxCADViewLib.AxCADViewX();
cadviewx1.SelfPopupMenu = false;
Mikhail

Re: How to capture Keyboard and Mouse input?

Posted: 03 Feb 2016, 10:33
by clho40
Hello,

Thanks for your reply. Setting SelfPopupMenu = false; worked for me. Thank you so much.

However,

I've tried
AxCADViewX.OnKeyDown
AxCADViewX.OnKeyPress


but there is no way for me to capture keys combination, like Ctrl + Shift + A. How can I do that please?

Thanks

Re: How to capture Keyboard and Mouse input?

Posted: 03 Feb 2016, 15:35
by support
Hello,

Have you tried the code below?

Code: Select all

private void axCADViewX1_OnKeyDown(object sender, AxCADViewLib.ICADViewXEvents_OnKeyDownEvent e)
{
   if (e.shift == CADViewLib.TxShiftState.ssCtrl && e.shift == CADViewLib.TxShiftState.ssShift && e.key == 65)
   {
      MessageBox.Show("Ctrl+Shift+A is pressed");
   }
}
Mikhail

Re: How to capture Keyboard and Mouse input?

Posted: 04 Feb 2016, 04:23
by clho40
Hello,

yes I've tried the following code

Code: Select all

this.CADViewX1.OnKeyDown += new AxCADViewLib.ICADViewXEvents_OnKeyDownEventHandler(this.CADViewX1_OnKeyDown);
private void CADViewX1_OnKeyDown(object sender, AxCADViewLib.ICADViewXEvents_OnKeyDownEvent e)
        {
            if (e.shift == CADViewLib.TxShiftState.ssCtrl && e.shift == CADViewLib.TxShiftState.ssShift && e.key == 65)
            {
                MessageBox.Show("A");
            }
        }
But when I press the combination, no response. The event is not fired when I press any key

Thanks

Re: How to capture Keyboard and Mouse input?

Posted: 04 Feb 2016, 08:46
by support
Hello,

The OnKeyDown event doesn't work, you can try to capture Ctrl+Shift+A keypress using a PreviewKeyDown event.


Mikhail

Re: How to capture Keyboard and Mouse input?

Posted: 05 Feb 2016, 04:27
by clho40
Hello,

Thanks! PreviewKeyDown event worked!