Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED]How to use MouseMoveEvent()?  (Read 5060 times)

0 Members and 1 Guest are viewing this topic.

Chuckleluck

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
[SOLVED]How to use MouseMoveEvent()?
« 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]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SOLVED]How to use MouseMoveEvent()?
« Reply #1 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
Laurent Gomila - SFML developer

Chuckleluck

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
[SOLVED]How to use MouseMoveEvent()?
« Reply #2 on: November 14, 2011, 11:19:16 pm »
Ah, thank you.  :D

EDIT: Are there similar functions for capturing mouse clicking?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SOLVED]How to use MouseMoveEvent()?
« Reply #3 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.
Laurent Gomila - SFML developer

 

anything