Ctrl-click detection

SDL (1.2.13, Windows XP) has no reliable way of detecting ctrl-click
combinations.

SDL_GetModState doesn’t work because it doesn’t report the modifier
state at the time of the event. Consider this sequence:

  • User pressed ctrl.
  • User clicks mouse button.
  • User releases ctrl.
  • Application handles the click event, but doesn’t see that ctrl was
    pressed at the time of the click.

Remembering the modifier state from the last SDL_KEYDOWN or SDL_KEYUP
event works better, but requires careful handling of SDL_KEYUP events.

There are two possible solutions to this problem.

  1. Add a ‘mod’ member to all mouse events. Unfortunately this may
    break backwards compatibility.
  2. Modify SDL_GetModState to reliably return the modifier state at the
    time of the last event that has been passed to the application.–
    Rainer Deyke - rainerd at eldwood.com

SDL (1.2.13, Windows XP) has no reliable way of detecting ctrl-click
combinations.

SDL_GetModState doesn’t work because it doesn’t report the modifier
state at the time of the event. Consider this sequence:

  • User pressed ctrl.
  • User clicks mouse button.
  • User releases ctrl.
  • Application handles the click event, but doesn’t see that ctrl was
    pressed at the time of the click.

Remembering the modifier state from the last SDL_KEYDOWN or SDL_KEYUP
event works better, but requires careful handling of SDL_KEYUP events.

There are two possible solutions to this problem.

  1. Add a ‘mod’ member to all mouse events. Unfortunately this may
    break backwards compatibility.
  2. Modify SDL_GetModState to reliably return the modifier state at the
    time of the last event that has been passed to the application.

I’d vote for #1. It’s simpler and the events struct has already been changed
in 1.3, so this is a pretty good place to add it in.>----- Original Message ----

From: Rainer Deyke
Subject: [SDL] Ctrl-click detection

just record the modifier state on SDL_MOUSEBUTTONDOWN, then use the value
recorded.On Thursday 09 Apr 2009 19:06:00 Rainer Deyke wrote:

SDL (1.2.13, Windows XP) has no reliable way of detecting ctrl-click
combinations.

SDL_GetModState doesn’t work because it doesn’t report the modifier
state at the time of the event. Consider this sequence:

  • User pressed ctrl.
  • User clicks mouse button.
  • User releases ctrl.
  • Application handles the click event, but doesn’t see that ctrl was
    pressed at the time of the click.

Remembering the modifier state from the last SDL_KEYDOWN or SDL_KEYUP
event works better, but requires careful handling of SDL_KEYUP events.

There are two possible solutions to this problem.

  1. Add a ‘mod’ member to all mouse events. Unfortunately this may
    break backwards compatibility.
  2. Modify SDL_GetModState to reliably return the modifier state at the
    time of the last event that has been passed to the application.

Kenneth Bull wrote:

just record the modifier state on SDL_MOUSEBUTTONDOWN, then use the value
recorded.

By the time I get the SDL_MOUSEBUTTONDOWN event, the modifier state is
already lost.–
Rainer Deyke - rainerd at eldwood.com

Rainer Deyke skrev:

SDL (1.2.13, Windows XP) has no reliable way of detecting ctrl-click
combinations.

Already discussed in this thread:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-March/064545.html

Rainer Deyke wrote:

Kenneth Bull wrote:

just record the modifier state on SDL_MOUSEBUTTONDOWN, then use the value
recorded.

By the time I get the SDL_MOUSEBUTTONDOWN event, the modifier state is
already lost.

There is this:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_GetModState

But I don’t know about the caveats of its usage.–
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia

Erik skrev:

Rainer Deyke skrev:

SDL (1.2.13, Windows XP) has no reliable way of detecting ctrl-click
combinations.

Already discussed in this thread:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-March/064545.html

Seems like the numbering changed. It is here now:

http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-March/064562.html