cannot check if key is pressed inside mouse event handler

I have a problem with the input, I’m unable to see if a key is pressed inside a mouse event, is this impossible? I attach the relevant code.

void mouse1(const Event *ev, void *data){
     //this is reached
     if (mouseWatcher->is_button_down(KeyboardButton::control())){
         //This is never reached even though control is pressed
     }
}

framework.define_key ( "mouse1", "Mouse 1 Action", &mouse1, NULL );

i’ve also tried with lcontrol(), rcontrol() and with any other key, nothing will work. It works outside the mouse event handler, though, for example in a task, the problem only occurs inside the mouse1 function.

thanks in advance.

Hmm, works fine for me. Are you sure you have the right MouseWatcher pointer, or there isn’t some other silly mistake?

Also note that, depending on how you’ve configured the ButtonThrower, you may get a different event name when the control key is held down: control-mouse1 instead of mouse1, which would mean that you might be listening for the wrong event name when the control key is held. This is the default configuration set up by WindowFramework. But since you say you’re reaching the event callback, I guess this isn’t your problem.

David

Fixed. I just had to listen separately for “control-mouse1” as you suggested. Just made a silly error while debugging, the code was indeed unreached when I wasn’t pressing Ctrl. Thanks!