-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard Event Disabled #18
Comments
I have the same issue: Steps to reproduce: Workarround: Use ProcessCmdKey and ProcessDialogKey in the mean time. |
@seanofw any ideas? |
I just built and tested the GLControl Input Test program, and it's working fine: I get KeyDown and KeyUp messages, both in native and WinForms mode. @userolle and @MarcioAB, have you tried compiling the GLControl Input Test program to see if that's misbehaving for you? I can't reproduce the failures you're describing. |
Before follow this route (built GLControl Input Test) I just tested with a simple WinForms application with only nuget OpenTK.WinForms (4.0.0-pre6) and KeyDown still does not work when the control is dropped into de Form. |
Same issue with "GLControl Input Test" program. |
I also have run into this issue. After adding OpenTK.WinForms (4.0.0-pre.6) on NetCore 3.1 WinForms project and dropping the GLControl on the Form - onKeyDown() is not fired neither on the GLControl, nor on the host Form. However, interestingly enough when setting GLControl.Enabled = false, the OpenGL Context is still active AND the KeyDown event is being invoked on the Form... P.S. KeyPreview = true for both test cases (MS VisualStudio Community 2019 v16.11.10) |
Globalement c'est un problème de Focus. Le formulaire et le glcontrol ne le reçoivent pas à l'ouverture. |
@MarcioAB are you able to try doing what is suggested here? this.Shown += new System.EventHandler(this.Form1_Shown);
private void Form1_Shown(object? sender, EventArgs e)
{
bool ret = Focus();
} |
@NogginBops Yes, but it still does not work. Program pass on Form1_Show(..) but still does not pass on OnKeyDown(..). |
After looking into the GLFW code of GLControl, I also considered that the issue is related to the focus of the NativeWindow which is created in the background. I noted that after starting the application the KeyPreviewEvent on the GLControl was called, but not passed to the Form. After minimizing and showing the form - the issue was resolved, so I forced GLControl.Focus() in the Form.Shown event. Doing what is propsed by @FrancisMartin-VB and @NogginBops is identical, and also works in my case. |
Over here forcing GLControl.Focus() does not solve the problem, including minimizing and showing the form. |
I have the same issue but ProcessCmdKey and ProcessDialogKey don't work for me either. |
It seems that one of the problems is that GLControl isn't entirely focusable/selectable. I have buttons next to the GL control, and clicking a button breaks the keyboards stuff not registering key presses. Even clicking on the GL control still appears to retain focus the button I clicked before. If I press the tab key to cycle to the GL control, it registers key presses again. EDIT: After some testing, I was calling GLControl.Focus in VisibilityChanged event, and the native window gains focus and then immediately loses it (GLFW unsets itself?) |
I was struggling with this issue for some time but I finally figured it out: I focused the GLControl in the mousedown event, as is done in the test example: GLControl/OpenTK.WinForms.InputTest/Form1.cs Line 103 in 4796dec
Hopefully this helps out any future folks who run into this same issue. |
I have also had issues with key events not triggering as expected with the GLControl. I have a form with a GLControl that takes all space on the form so no other controls on the form and this causes issues for me with form key events not triggering until I have minimized/maximized/alt-tabbed the form. Once the events started to trigger I could not get the "KeyDown" event to trigger for arrow keys. I addad a text control to the form and everything started working as expected again. So there is deffenetly something with the focus that is causing the issue. I have not tested much with the native input events but I noticed basicly the same pattern with them. Hope this helps someone in the future or maybe someone can find a fix :) |
After using this GLControl in my form, The events like KeyDown KeyPress etc don't work anymore, not just for GLControl but for the form as well. Does anyone know why and how to fix this? (KeyPreview set to true already)
The text was updated successfully, but these errors were encountered: