
GLControl Disables Arrow Keys From Raising Form's KeyDown Event . . . . .
Posted Thursday, 24 September, 2009 - 14:17 by casanovaC4| Project: | The Open Toolkit library |
| Version: | 0.9.8-3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hy,
I tried to use GLControl's own KeyDown Events to use in my application but Arrow Keys(up, down, left, right) do not raise it's events.
But then i tried to use Form's KeyDown Events and Arrow Keys were not working here either but the rest of the keys do.
Then i used Windows.Panel and checked to make sure if there was nothing with the Form but here both Panel's and Form's KeyDown Events were being raised by Arrow Keys.
I have supplied code in C# which explains the problem a lot clearly.
Just try commenting and uncommenting and see it for yourself.
OpenTK version used : 0.9.8.3.
Problem persists in : 0.9.9.2b as well.
| Attachment | Size |
|---|---|
| OpenTK Bug Report.zip | 1.79 KB |


Comments
#1
This is actually because the Control consumes those keys by default.
Derive from the GLControl and add the following method override:
This will mean that certain child controls will lose tab navigation, text entry, etc. if you consume those key events so you can selectively enable the ones that are required.
#2
Thanks for the pointer. casanovaC4, can you please test whether this solves the issue for you?
#3
Yes the above solution did solve my problem.
But I think GLControl should not alter Form's own KeyDown Events.
Anyhow It's working now.
Thank you very much.
Kind Regards.
#4
Thanks for confirming.
This is a general issue that stems from the Windows.Forms design, rather than something specific to GLControl-specific. GLControl itself does not interact with the keyboard/mouse in any way: these events are provided by the base
System.Windows.Forms.UserControlclass (i.e. we cannot alter its implementation).#5
Is there alternatives to inheriting from GLControl to make arrow keys work?
#6
Yes, handle the PreviewKeyDown event.