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

Author Topic: Differenciating mouse click and mouse drag  (Read 1997 times)

0 Members and 1 Guest are viewing this topic.

flashrocket

  • Newbie
  • *
  • Posts: 21
    • View Profile
Differenciating mouse click and mouse drag
« on: May 04, 2014, 02:02:02 pm »
I want to perform different actions for mouse clicked and mouse dragged.
mouse drag means click and move mouse.

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Differenciating mouse click and mouse drag
« Reply #1 on: May 04, 2014, 02:57:01 pm »
So yeah... :D

Why don't you then go ahead and implement these things?
Or don't you know how to and ask for something specific?
Failing to succeed does not mean failing to progress!

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Differenciating mouse click and mouse drag
« Reply #2 on: May 04, 2014, 03:00:06 pm »
The MouseButtonPressed, MouseButtonReleased and MouseMoved events should be all you need to implement drag-and-drop behavior.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Differenciating mouse click and mouse drag
« Reply #3 on: May 04, 2014, 03:02:51 pm »
So, what you want is something like the following (I guess).

If you get a mouse down event this might mean either click or drag, so we'll defer judgement to later. For now just remember that we've received a down event.
If we receive a mouse up event without any mouse move events in between, then this was a click, so do whatever clicking is supposed to do.
If we get a move event before any up event then that's a signal that the user started a drag, so remember that so that when the mouse up event comes we can do whatever drag does.

Am I close? If not then please describe your problem in more detail.

flashrocket

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Differenciating mouse click and mouse drag
« Reply #4 on: May 04, 2014, 03:20:18 pm »
@Jesper Juhl
Thanks that was exactly what i wanted.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Differenciating mouse click and mouse drag
« Reply #5 on: May 04, 2014, 04:11:24 pm »
@Jesper Juhl
Thanks that was exactly what i wanted.

Great  :)
In the future you could help yourself a bit by being a bit more explicit about what you are asking. It wasn't entirely clear to me if you were expecting SFML to have some explicit drag-n-drop support or if you just didn't know how to build it yourself or something else. Extra details and explicit questions make everything easier for everyone.