How click events handled ? |
deco33000
Guest
|
Hello,
It maybe kind of noobish but I read the code implementing the events in SDL_events.c. Could someone confirm that when one click occurs, one has to iterate over the attached event linked-list and compare each one to know if the event is his ? That way, it is a linear event handler. I may have missed something though. Thanks --š Jog _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
How click events handled ? |
Daniel Gibson
Guest
|
Not sure I understand your question properly, but usually you'd use
SDL_PollEvent() each frame and react to the events (keys pressed, mouse buttons pressed, mouse moved, ...) there. Like in https://gist.github.com/DanielGibson/12041b57a540cbbfbaf9#file-sdl2test-c-L14 and following (it returns 0 if there are no more events) There's also SDL_GetMouseState() and SDL_GetRelativeMouseState() that you can call to check if a button is currently pressed. See also: https://wiki.libsdl.org/SDL_PollEvent https://wiki.libsdl.org/SDL_GetMouseState Cheers, Daniel On 06/09/2015 05:59 PM, wrote:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
How click events handled ? |
deco33000
Guest
|
Thanks,
Indeed my question was not clear enough. I was talking about the structure to manage the click event. -------- When a user clicks a button with the mouse, say the "File" menu, it triggers an event. There must be an information somewhere saying that pixel X to X+z is assigned to the menu's "File" listener, right ? (or is it not working that way ?) So, is the event going through a linked list of events managed by the SDL, or is it using the system's native event handler like select/poll/epoll/kqueue... ? I hope it is better now --š Jog _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
How click events handled ? |
Jared Maddox
Guest
|
It sounds like you're looking for widgets. There's some work to improve SDL's support for external widget systems, but SDL itself does not directly provide a widgeting system. If you want e.g. a File menu (or any menu, really) then you'll need to either implement it from scratch, or use another library. If a platform widget message somehow reaches SDL, then it'll presumably show up as a platform-specific event. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
How click events handled ? |
deco33000
Guest
|
Got it, it is system dependent and not directly SDL related.
Seems good ! Thanks! --š Jog _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|