How to capture Keyboard and Mouse input?

Discuss and ask questions about CADViewX (Lite and Pro versions).

Moderators: support, SDS, admin

Post Reply
clho40
Posts: 7
Joined: 25 Jan 2016, 04:39

How to capture Keyboard and Mouse input?

Post by clho40 » 02 Feb 2016, 13:11

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.

support
Posts: 2930
Joined: 30 Mar 2005, 11:36
Contact:

Re: How to capture Keyboard and Mouse input?

Post by support » 03 Feb 2016, 09:11

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
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

clho40
Posts: 7
Joined: 25 Jan 2016, 04:39

Re: How to capture Keyboard and Mouse input?

Post by clho40 » 03 Feb 2016, 10:33

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

support
Posts: 2930
Joined: 30 Mar 2005, 11:36
Contact:

Re: How to capture Keyboard and Mouse input?

Post by support » 03 Feb 2016, 15:35

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
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

clho40
Posts: 7
Joined: 25 Jan 2016, 04:39

Re: How to capture Keyboard and Mouse input?

Post by clho40 » 04 Feb 2016, 04:23

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

support
Posts: 2930
Joined: 30 Mar 2005, 11:36
Contact:

Re: How to capture Keyboard and Mouse input?

Post by support » 04 Feb 2016, 08:46

Hello,

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


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

clho40
Posts: 7
Joined: 25 Jan 2016, 04:39

Re: How to capture Keyboard and Mouse input?

Post by clho40 » 05 Feb 2016, 04:27

Hello,

Thanks! PreviewKeyDown event worked!

Post Reply