cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
SDL 2.0 - Good way of handling mouse inp
SDL 2.0 - Good way of handling mouse input?
Oct 8, 2013 at 1:27am UTC
roger911
(127)
I'm trying to create a method that deduces mouse motion WHILE the left button is clicked. Does anyone know a way to do this?
Oct 8, 2013 at 3:06am UTC
Disch
(13742)
1) Catch the MouseButtonPressed event. Set a boolean value to indicate the L button is clicked.
2) Catch the MouseButtonReleased event. When L button is released, clear your boolean.
3) Catch the MouseMove event. Only process when your boolean indicates the L button is clicked.
Oct 8, 2013 at 5:32am UTC
roger911
(127)
Thanks, had some trouble catching the release because of SDL_Delay used in my fps limiter. Ended up polling for events 2 times, before and after the fps limiter.
Oct 8, 2013 at 2:16pm UTC
Disch
(13742)
Events should say in the queue until you pull them out. How long you delay wouldn't matter.
There might be multiple events in the queue, so you should always empty the queue with a while() statement and not a single if statement:
1
2
3
4
while
( wnd.pollEvent(...) )
// <- while, not if
{
// handle event
}
Topic archived. No new replies allowed.