How click events handled?

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

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


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,
DanielOn 06/09/2015 05:59 PM, deco33000 at yandex.com wrote:

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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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 :slight_smile:
–?
Jog

Message-ID: <4253821433877838 at web19g.yandex.ru>
Content-Type: text/plain; charset=koi8-r

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 :slight_smile:
–?
Jog

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.> Date: Tue, 09 Jun 2015 21:23:58 +0200

From: deco33000 at yandex.com
To: SDL Development List
Subject: Re: [SDL] How click events handled ?

Got it, it is system dependent and not directly SDL related.

Seems good !

Thanks!

–?
Jog