SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Use SDL_CreateWindowFrom to create a window, unable to get the keyboard SDL_KEYDOWN event

Open atfeel opened this issue 3 years ago • 8 comments

Hello author After using SDL_CreateWindowFrom(hwnd) to create a window, using SDL_WaitEvent(&vEvent) to get the keyboard SDL_KEYDOWN and SDL_KEYUP events, what should I do?

atfeel avatar Dec 28 '21 06:12 atfeel

It's assumed that if you're creating the window yourself, you're also handling events for that window. What is your use case?

slouken avatar Dec 28 '21 17:12 slouken

I use C# to write a winform program. In SDL_CreateWindowFrom(hwnd), hwnd is the handle of PictureBox. Does SDL support this usage? Do I need to handle and intercept keyboard events by myself?

atfeel avatar Dec 29 '21 04:12 atfeel

You do right now, but I can add a hint in 2.0.22

slouken avatar Dec 29 '21 18:12 slouken

I'd be interested in having a flag for this, too.

mokafolio avatar Jun 21 '22 23:06 mokafolio

Another use case for this is to be able to make audioplugins for musicprograms that use SDL2 for making GUI's. It is standard to get a window handle from the music program to take over, otherwise the audio-plugins can't operate as expected. Examples of this in the VST and VSTi standard or the CLAP audio plugin format. And it would be great as these audio plugins is expected to be converted to different platforms.

People have wanted to use SDL for making GUI's for audio plugins, but it's commonly known that it's not possible as people have tested and failed. And the missing link is SDL_CreateWindowFrom() dosn't give you normal SDL2 events from a window that SDL has taken over. You can draw to the window, but you don't get any SDL events.

What is the use of SDL_CreateWindowFrom() if you don't get any events anyway? So this functionality mentioned is a must if SDL2 should be used for making GUI's for audio plugins. And it would be a great usecase as SDL is phenomenal for easy use of bitmap graphics that most of all audio plugin uses.

logos-maker avatar Nov 25 '22 19:11 logos-maker

I'm testing with testnative on Windows and am getting keyboard events. Can someone post a link to a sample that isn't getting events, so we can debug?

slouken avatar Nov 14 '23 03:11 slouken

I am pretty certain that the behavior was not consistent across platforms. Will try to put up a sample for at least linux and osx in the next couple of days to refresh my memory.

I also just want to clarify that I certainly think this should be an optional feature. There are still use cases where you just want to use SDL for window/surface management for a native window, while the events are handled by a different part of the application.

mokafolio avatar Nov 15 '23 16:11 mokafolio

Hi, for reference I am not getting any events on Linux when passing an X11 window via "SDL_CreateWindowFrom()".

icamaster avatar Jan 01 '24 18:01 icamaster