SFML community forums

Help => General => Topic started by: Chuckleluck on November 14, 2011, 08:51:21 pm

Title: [SOLVED]How to use MouseMoveEvent()?
Post by: Chuckleluck on November 14, 2011, 08:51:21 pm
I'm wanting to pass the position of the mouse in X and Y coordinates as a arguments in a function.  I thought the easiest way would be to use Event::MouseMoveEvent(), so I wrote this code:
Code: [Select]
if(Event.Type == sf::Event::MouseMoved)
HandleMouse(sf::Event::MouseMoveEvent.X, sf::Event::MouseMoveEvent.Y);

This is in the main program loop.  However, when I try to run the program, it gives me the error on the line HandleMouse is on:
" error: expected primary-expression before ' . ' token "
I assumed capturing the mouse coordinates was the purpose of MouseMoveEvent.  Could someone,
A. Tell me what's wrong with this code, or
B. If MouseMoveEvent isn't the right function, point me to another function that suits my needs.[/quote]
Title: [SOLVED]How to use MouseMoveEvent()?
Post by: Laurent on November 14, 2011, 09:14:03 pm
sf::Event::MouseMoveEvent is the type, the instance is Event.MouseMove.

So:
Code: [Select]
Event.MouseMove.X
Event.MouseMove.Y
Title: [SOLVED]How to use MouseMoveEvent()?
Post by: Chuckleluck on November 14, 2011, 11:19:16 pm
Ah, thank you.  :D

EDIT: Are there similar functions for capturing mouse clicking?
Title: [SOLVED]How to use MouseMoveEvent()?
Post by: Laurent on November 15, 2011, 07:28:15 am
Of course. Read the doc and tutorials.

And they are not functions, but members of the sf::Event type.