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

Author Topic: Detect the mouse leaving the window  (Read 2460 times)

0 Members and 1 Guest are viewing this topic.

Arjan B

  • Newbie
  • *
  • Posts: 4
    • View Profile
Detect the mouse leaving the window
« on: June 12, 2010, 11:48:41 am »
I am making a puzzle game in which you drag stones with your mouse.
After letting several users test-play the game, I've noticed they all have this urge to click a stone, just sweep the mouse in the direction they want it to move and then release the button.
While doing this, very often the mouse moves outside of the window and the button is released there. This gets to the point where it ruins the gameplay and players get agitated.

When I googled on this problem I came upon this thread:
http://www.sfml-dev.org/forum/viewtopic.php?t=2597&sid=4b204b044470280bf28e8856ae1b34e5

Is there really no way I could check for the mouse to leave the window? Or does anyone have a different solution to my problem?

Thank you in advance,
Arjan

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Detect the mouse leaving the window
« Reply #1 on: June 12, 2010, 01:18:39 pm »
So, do you want to detect mouse leaving the window, or button released outside the window?
Laurent Gomila - SFML developer

Arjan B

  • Newbie
  • *
  • Posts: 4
    • View Profile
Detect the mouse leaving the window
« Reply #2 on: June 12, 2010, 01:58:48 pm »
Any one of those would do ^^.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Detect the mouse leaving the window
« Reply #3 on: June 12, 2010, 09:45:34 pm »
This is something that I'll probably think about for SFML 2.
Laurent Gomila - SFML developer

Arjan B

  • Newbie
  • *
  • Posts: 4
    • View Profile
Detect the mouse leaving the window
« Reply #4 on: June 13, 2010, 03:30:58 am »
Quote from: "Laurent"
This is something that I'll probably think about for SFML 2.


That's nice ^^.

For now, I'll make the game deselect a block as soon as it collides with the puzzle's border (not really fair, because they might accidentally hit the border when not wanting to place the block near it, but it's a fix for now).

Thank you for your help!

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Detect the mouse leaving the window
« Reply #5 on: June 14, 2010, 07:23:31 am »
You could do basically what you said in your last post :) lol

You could lock the mouse inside the window - this can be a little disconcerting when you don't expect it though, but if you have a menu or something on Esc button then you could just release it then.

Make your game fullscreen?

Arjan B

  • Newbie
  • *
  • Posts: 4
    • View Profile
Detect the mouse leaving the window
« Reply #6 on: June 14, 2010, 05:43:11 pm »
Well, this game would mostly be played while doing something else at the same time. Like when you're chatting but in between conversation you play some puzzles.

So only allowing full-screen or locking the mouse to the window would annoy players a lot, I think ^^.

 

anything