MouseHeld firing only once


The MsgMouseButtonHeld is only getting fired the second frame the mouse is being held. This seems like unexpected behavior and might be better if it fired for every frame the mouse is held. This allows users to be able to test for dragging without hacking booleans together.
Closed Oct 3, 2012 at 5:43 AM by LordIkon
As designed, detailed solution to original problem in prior comment.


LordIkon wrote Oct 3, 2012 at 5:42 AM

This is as designed. The input system sends messages as events occur. You will receive a pressed message only when the mouse button is pressed, and a held message only as the mouse button becomes held.

If you would like to query frame-by-frame for a button being held then what you will want to use is an InputPollingHandler or a BaseInputComponent. A good reference on how to use this look at the FreeCameraInputComponent, located in QuickStart_Windows/Components/InputComponents/FreeCameraInputComponent.cs

Within this class notice the InitButtonListeners() function, where you register for the keyboard keys (or mouse buttons in your case) that you want to keep track of, and then notice that each frame in the ProcessInput() function it polls for the state of the keys it cares about.

The engine allows you to listen for any buttons events that fire, and through an InputPollingHandler, allows you to keep track of the states of buttons so that you can easily query those states at any time. This gives you the ability to do something the first time a button is held, and doing something every frame while a button is held.

wrote Oct 3, 2012 at 5:43 AM

wrote Feb 14, 2013 at 9:36 PM

wrote May 16, 2013 at 11:01 AM