I am trying to write a LispFunction Method that will Return the KeyCode.ToString value of a Windows Form KeyDown Event.
Why use the Windows Form?
Because I am new to .NET, and this is the only way I knew how to successfully access the KeyDown Event. If there's a better way to accomplish this - PLEASE let me know.
This code works well in a Windows Form solution (VB.NET, Form1 Class), but fails when attempting to pass the value to the myKey variable in the FooClass Class:
Public Class Form1
' I changed this from Sub to Function in an attempt to Return
' the KeyCode.ToString value to the LispFunction Method
Private Function Form1_KeyDown(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles MyBase.KeyDown
Dim bHandled As Boolean = False
'myKey = e.KeyCode.ToString ' <-- This is where I am confused
Debug.Print(e.KeyCode.ToString) ' <-- For Debug only
e.Handled = True
Me.Close()
End Function
End Class
... I am unable to figure out how to pass this variable back to the Root namespace (and Class) for my Add-In, so that it can be Returned from the original Method.
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
Imports System
Namespace FOO
Public Class FooClass
Private myKey As String = "" ' <-- Public, Private, nor Shared seems to work
<LispFunction("FOO")> _
Public Function FOO(ByVal args As ResultBuffer)
' Call Windows Form to initialize the KeyDown Event
' KeyDown Event received, and Windows Form Closed
' Pass KeyCode.ToString back to this function
' Return KeyCode.ToString As String
End Function
End Class
End Namespace
Any help would be greatly appreciated.