Hi folks,
I’m using the “MouseEventsSample” from the awesome PoScene block as boilerplate code to create five interactive objects which respond to different mouse interactions. All is good there.
Where I’m running into trouble is when trying to capture both KeyDown and KeyUp events. My VS 2013 Win32 project compiles fine but my PoScene project fails to recognize both events. It either recognizes KeyDown or KeyUp but not both. I need to capture the state of a modifier key (such as Alt) in order to change the scale of an object when the mouse is dragged.
I’ve tried an alternate way of connecting the signals as mentioned in this post but it also fails identically.
//https://forum.libcinder.org/topic/glnext-app-refactor-merge#23286000002290067
I’ve never experienced this problem before with Key events, really simple stuff. I’d appreciate any direction on this. After hammering away at it for several hours I’m completely stumped.
Thanks for any help, everyone.
Cheers,
Ken
void Square::setup()
{
mIsControlDown=false;
mIsAltDown = false;
// Connect to mouse events
getSignal(po::scene::MouseEvent::DOWN_INSIDE).connect(std::bind(&Square::onMouseDown, this, std::placeholders::_1));
getSignal(po::scene::MouseEvent::DRAG).connect(std::bind(&Square::onMouseDragged, this, std::placeholders::_1));
getSignal(po::scene::MouseEvent::UP_INSIDE).connect(std::bind(&Square::onMouseUp, this, std::placeholders::_1));
getSignal(po::scene::MouseEvent::UP).connect(std::bind(&Square::onMouseUp, this, std::placeholders::_1));
// Connect to key events
ci::app::getWindow()->getSignalKeyDown().connect(std::bind(&Square::keyDown, this, std::placeholders::_1));
ci::app::getWindow()->getSignalKeyUp().connect(std::bind(&Square::keyUp, this, std::placeholders::_1));
//THIS CODE ALSO COMPILES BUT FAILS TO RECOGNIZE BOTH KEY EVENTS
//https://forum.libcinder.org/topic/glnext-app-refactor-merge#23286000002290067
//ci::app::getWindow()->getSignalKeyDown().connect(signals::slot(this, &Square::keyDown));
//ci::app::getWindow()->getSignalKeyUp().connect(signals::slot(this, &Square::keyUp));
}
void Square::keyDown(ci::app::KeyEvent &event)
{
mIsControlDown = event.isControlDown();
mIsAltDown = event.isAltDown();
}
void Square::keyUp(ci::app::KeyEvent &event)
{
mIsControlDown = event.isControlDown();
mIsAltDown = event.isAltDown();
}