Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have created a basic add-on that shows a modal windows form. The only issue I am running into is that I am completely unable to capture any key events in the form. I just want to make the escape key close my form, but I'm having no luck. Here is my basic setup:
<CommandMethod("myCommand")> _ Public Sub myCommand() Dim myForm As Form1 = New Form1 Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(myForm) End Sub
Then in the form code, I have this, for testing purposes:
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress MsgBox("keypress") End Sub
I've also tried KeyUp and KeyDown. Key presses are working inside the form (I can use the keyboard to select an item in a combobox, for example), but I never hit the event handlers. Does anyone have a clue what I'm doing wrong here?
Thanks!
Solved! Go to Solution.