Is there an event with CEGUI::PushButton that can execute the callback while the button is being pressed but not released, just holding the button down. For example if you want to control a camera moving forward you would want to press the button and keep holding it to move properly. At the moment I am getting callback only after the button is being pressed but not while I am holding the button down.
Update: I found that I can use EventCursorPressHold. This is how I am doing it at the moment but it seems messy and the one thing that doesn't work is when I have pressed the button but I move my cursor outside of the button I cannot stop the event I tried using EventInputCaptureLost, EventCursorLeavesArea, EventCursorLeavesSurface but all of them work only when the EventCursorPressHold has finished. Is there a way to execute two events at the same time maybe ?
It seems that when I have two buttons with events if you try and press them at the same time it doesn't work the Event::Subscriber is waiting for the first event to finish before it executes the second button event.
Code: Select all
//CEGUI events subscribers
button->subscribeEvent(CEGUI::PushButton::EventCursorPressHold, CEGUI::Event::Subscriber(&OgreFramework::mMoveForward, this));
button->subscribeEvent(CEGUI::PushButton::EventInputCaptureLost ,CEGUI::Event::Subscriber(&OgreFramework::mStopMovement, this));
//Movement
void OgreFramework::moveCamera()
{
m_pCamera2->moveRelative(m_TranslateVector / 10);
}
bool OgreFramework::mMoveForward(const CEGUI::EventArgs &e)
{
bMoveForward = true;
return true;
}
bool OgreFramework::mStopMovement(const CEGUI::EventArgs &e)
{
bMoveForward = false;
return true;
}
void OgreFramework::TranslateCamera()
{
if(bMoveForward) m_TranslateVector.z = -m_MoveScale ;
}
//Update
void OgreFramework::updateOgre(double timeSinceLastFrame)
{
m_MoveScale = m_MoveSpeed * (float)timeSinceLastFrame;
m_RotScale = m_RotateSpeed * (float)timeSinceLastFrame;
m_TranslateVector = Vector3::ZERO;
TranslateCamera();
moveCamera();
m_FrameEvent.timeSinceLastFrame = timeSinceLastFrame;
CEGUI::System::getSingleton().injectTimePulse(timeSinceLastFrame);
}