Mouse Buttons

Hi,

In my little SDL app test, I have the attached code piece.
The problem is that the RELEASE part of Mouse Button check
appears not to be working. I’m doing something wrong?

[]s,

Herbert
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: codepart.cpp
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030214/6f8e75ac/attachment.asc

the way I understand it, is that you need to check for MOUSEBUTTONUP.

PRESSED and RELEASED are simply the _current_state of the mouse, not the
event’s state.

i.e. if you press down up before the event system can process. you get
two events. both events are going to list the event state -AND- the
current state.

you want to check the event state probably, which is what you have for
down, plus another case for MOUSEBUTTONUP (see the docs.)

note, the docs aren’t too clear on this, so I’m just guessing based on
what I’ve gotton to work, and by reasoning why there would be a second
state (the PRESSED or RELEASED one) in the event structure.

basically you can ignore pressed/released unless you need the absolute
current state - but then you’ll miss events.

  • kevinOn Fri, 14 Feb 2003, Herbert G. Fischer wrote:

Hi,

In my little SDL app test, I have the attached code piece.
The problem is that the RELEASE part of Mouse Button check
appears not to be working. I’m doing something wrong?

[]s,

Herbert

I see. Now it make sense to me. So, we know that the SDL Manual is wrong or
confusing:

“Like SDL_KeyboardEvent, information on whether the event was a press or a
release event is stored in both the type and state fields, but this should
be obvious.”

http://sdldoc.csn.ul.ie/sdlmousebuttonevent.php> ----- Original Message -----

From: kevin@vrsource.org (Kevin Meinert)
To:
Sent: Friday, February 14, 2003 3:17 PM
Subject: Re: [SDL] Mouse Buttons

the way I understand it, is that you need to check for MOUSEBUTTONUP.

PRESSED and RELEASED are simply the _current_state of the mouse, not the
event’s state.

i.e. if you press down up before the event system can process. you get
two events. both events are going to list the event state -AND- the
current state.

you want to check the event state probably, which is what you have for
down, plus another case for MOUSEBUTTONUP (see the docs.)

note, the docs aren’t too clear on this, so I’m just guessing based on
what I’ve gotton to work, and by reasoning why there would be a second
state (the PRESSED or RELEASED one) in the event structure.

basically you can ignore pressed/released unless you need the absolute
current state - but then you’ll miss events.

  • kevin

On Fri, 14 Feb 2003, Herbert G. Fischer wrote:

Hi,

In my little SDL app test, I have the attached code piece.
The problem is that the RELEASE part of Mouse Button check
appears not to be working. I’m doing something wrong?

[]s,

Herbert


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Herbert G. Fischer wrote:

I see. Now it make sense to me. So, we know that the SDL Manual is
wrong or confusing:

“Like SDL_KeyboardEvent, information on whether the event was a press
or a release event is stored in both the type and state fields, but
this should be obvious.”

http://sdldoc.csn.ul.ie/sdlmousebuttonevent.php

It’s not wrong, but it is indeed potentially confusing. I assume it is
merely trying to say that the information is effectively duplicated, and
that when type = SDL_MOUSEBUTTONDOWN state will always equal
SDL_PRESSED, and when type = SDL_MOUSEBUTTONUP then state =
SDL_RELEASED. It does refer to SDL_KeyboardEvent which has a better
example.

If you think about it, for your code to work, SDL would have to be
sending both SDL_MOUSEBUTTONDOWN and SDL_MOUSEBUTTONUP messages when
the mouse button is pressed (or released), so that people who chose to
only handle one of the two types of event (as in your code) can
potentially receive both states. This is obviously wrong.–
Kylotan
http://pages.eidosnet.co.uk/kylotan