AB4D Forum
Capture Keypress in elementhost1 - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9)
+--- Thread: Capture Keypress in elementhost1 (/showthread.php?tid=4244)



Capture Keypress in elementhost1 - GraPhiX - 03-02-2021

Hi
i have converted most of the Duck Lake sample, but i am having a problem getting the keypress event it never catches the keypress any idea how i can get it to work, this is VB.NET with elementhost btw.

Code:
Private Sub ElementHost1_KeyDown(sender As Object, e As Forms.KeyEventArgs) Handles ElementHost1.KeyDown


       Select Case e.KeyCode
           Case Key.F1 'Move
               CHK_MoveModel.Checked = True
               e.Handled = True
           Case Key.F2 'Rotate
               CHK_RotateModel.Checked = True
               e.Handled = True
           Case Key.F3 'Scale
               CHK_ScaleModel.Checked = True
               e.Handled = True
       End Select
   End Sub
thank you for any help you can give :)


RE: Capture Keypress in elementhost1 - abenedik - 03-03-2021

To get keystorkes in WinForms application I would advice you to use the method in WinForms. I am not an expert for WinForms, but you may try to subscribe to KeyDown event in the Form object.


RE: Capture Keypress in elementhost1 - GraPhiX - 03-03-2021

(03-03-2021, 07:53 PM)abenedik Wrote: To get keystorkes in WinForms application I would advice you to use the method in WinForms. I am not an expert for WinForms, but you may try to subscribe to KeyDown event in the Form object.

yes i have used the form keydown event, it originally did not work until i changed keypreview to true in the form properties, sometimes you have to step back and look at it again, was a simple fix in the end :)