SOLVED: SignalKeyUp Function fails to fire in PoScene Win 32 project

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();
}

Hi guys,

I figured out the problem was I had breakpoints set up in the KeyDown and KeyUp methods. I replaced these with Console() trace statements and realized that both the KeyDown and KeyUp events were firing as expected.

I guess it makes sense that the VS 2013 debugger would fail to call the KeyUp function if I was paused on a breakpoint in the KeyDown function then pressed the “Continue” button in the IDE.

However, this did come as a surprise to me since I thought the whole purpose of breakpoints was allowing the programmer to step through their code as it executed.

Anyway, live and learn. I hope someone else finds this useful.

Cheers,

Ken

1 Like