0

I'm using SdlDotNet 6.1 and i love it :)

My SurfaceControl WinForm control (pictureBox), i don't receive key up and down events All others events (MouseDown, MouseMotion, Tick) seems working only after call Events.Run() (which lock the thread...)

The WinForm event "PreviewKeyDown" isn't raised too.

I found the SurfaceControl needs the focus to raise these events. I use mySurfaceControl.Select() on MouseMove event to force focus on it.

My problem is the keyboardDown event is not raised on every key... It raised on A-Z Escape NumLock Enter Space F1-12 Pause Home Delete. It NOT raised on Ctrl Shift Tab Return 1-9 1-9(num) arrows symbols. Alt and Alt-Gr is raised as Keys.Menu.

My Azerty keyboard (sorry i'm french) is not the cause, i have tested in Qwerty mode.

All keys are detected on the WinForm event "PreviewKeyDown", but WinForm don't provide a PreviewKeyup event...

So Keyboard.IsKeyPressed always return false and KeyboardState return 323 false but Events.IsEventEnabled() is true.

I need detect when A-Z are pressed : OK I need detect if Ctrl/Shift/Alt is pressed : NOT OK

Any ideas ? Thank you.

Baud
  • 182
  • 1
  • 1
  • 8

1 Answers1

1

I tried IsInputKey=true (in PreviewKeyDownArgs) but no effect with the SDL event.

In fact, there are KeyDown and KeyUp event in addition of PreviewKeyDown but they are not displayed in properties window (Visual Studio 2010), and these events work. Unlike mouse events, these events need the focus on the control (Control.Select() give the focus).

These events help me, even if KeyboardState would have been easier !

Solved.

Baud
  • 182
  • 1
  • 1
  • 8