[vtkusers] key press / key release for hiding / showing an actor

Steffen Oeltze stoeltze at isg.cs.uni-magdeburg.de
Mon May 30 08:21:25 EDT 2011


Hi,

I derived my own interactor style. I would now like to implement the 
following behavior:

- press the space bar and hold it -> hide actor
- release the space bar -> show actor

For that purpose, I implemented the OnKeyPress() and OnKeyRelease() 
functions. When pressing the
space bar, the actor is hidden. However, after about a second, it 
appears again (while still pressing the
space bar) and the representation starts to flicker as if keypress and 
keyrelease events are continuously fired.

Do you have any idea how this problem may be solved?

Best Regards,
Steffen


void RubberBandStyle::OnKeyPress()
{
     if (this->Interactor->GetKeyCode() == VK_SPACE)
         object->showActor(false);
}

void RubberBandStyle::OnKeyRelease()
{
     if (this->Interactor->GetKeyCode() == VK_SPACE)
         object->showActor(true);
}




More information about the vtkusers mailing list