#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    3
    Rep Power
    0

    Post Trouble with the mouse_enter event


    Hello, I'm trying to make a minesweeper program. I'm mostly finished, but now I'm trying to add the little details.

    So you know how in minesweeper when you hold down your mouse button and move it around, the block that it's in presses down, and when you move it out of that block it pops back up?

    I have it now so that if the user presses the mouse button inside of a box then it presses down, and if they move the cursor outside of the box and then release the mouse then it pops back up.

    My problem is this: I can't get it so that when I enter a new box without releasing the mouse button, that box goes down.

    My method right now is to get an "If" statement in the Mouse_enter and Mouse_leave events for each box that checks whether the mouse is held down or not using a Boolean.

    But it isn't working because when the mouse enters the box with the button held down from a different box, it doesn't do anything. It only performs the code if the button isn't held down.

    I was wondering if anyone knows why this is that it doesn't perform the code if the button is held down already? Or, is there an easier way to do this? Thank you in advance.

    I apologize if the way I worded this is confusing. My thoughts are pretty jumbled. If you need clarification about anything, please ask.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    289
    Rep Power
    45
    I am not sure what you are using, but with VB6 the "MouseMove" event is what you would use. As the mouse is moved over an object, the event is triggered and code can be attached to it.

    J.A. Coutts
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    3
    Rep Power
    0
    Thank you for replying, but my problem is still happening when I use mouse_move instead. I'm running visual studio 2010.
    It doesn't work because when the mouse presses down on another block, and then drags outside of that block and moves over the new block without letting go of the mouse button, for some reason it doesn't activate that mouse_move code in the new block.
    I think maybe it's not registering because it's still trying to do something with the original block as long as the mouse is held down? It seems like maybe this is a just a problem with the way I'm trying to do it. Is there possibly some way that i should implement a drag/drop instead?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    289
    Rep Power
    45
    I assumed that you wanted to execute code as the mouse moved over an object, not with the mouse depressed. When you click the mouse, it initiates an action with the object it is currently pointing to. Other than Drag & Drop, you cannot carry that action elsewhere. When the mouse is released, the action is still carried out on the object it was originally pointing to. This behaviour has nothing to do with the programming language; it is a property of the operating system itself.

    J.A. Coutts

IMN logo majestic logo threadwatch logo seochat tools logo