Message 1 of 1
Overiding Inventor shortcuts while Addin is active.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am making an AddIn which is using a windows form. I am trying to make a simple copy paste functionality on my form but I is not letting me.
If I try a random key combinantion like Ctrl+A for coping to the clipboard it works, but the combination Ctrl+C is does not. I am working in an assembly. I think Inventor somehow reserves this key combination for the copy function in the assembly.
So my question would be, how can I override shortcuts in the assembly while the windows form is active or in focus?
Here is my code in the windows form:
' COPY AND PASET FUNCTIONALITY
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
' Copy to clipboard when Ctrl+C is pressed
If e.Control AndAlso e.KeyCode = Keys.C Then
'If e.Control AndAlso e.KeyCode = Keys.C Then
'g_konfiguratorForm.PrintToLog("Ctrl+C")
Dim activeControl As Control = Me.ActiveControl
If activeControl IsNot Nothing AndAlso IsWritableControl(activeControl) Then
Clipboard.SetText(activeControl.Text)
End If
End If
' Paste from clipboard when Ctrl+V is pressed
If e.Control AndAlso e.KeyCode = Keys.V Then
'g_konfiguratorForm.PrintToLog("Ctrl+V")
Dim activeControl As Control = Me.ActiveControl
If activeControl IsNot Nothing AndAlso IsWritableControl(activeControl) Then
activeControl.Text = Clipboard.GetText()
End If
End If
End Sub
Private Function IsWritableControl(control As Control) As Boolean
Return TypeOf control Is TextBoxBase OrElse
TypeOf control Is ComboBox OrElse
TypeOf control Is ListBox OrElse
TypeOf control Is DataGridView
' Add more control types if needed
End Function