[vtkusers] KeyPressEvent callback functions not responding with MFC
Mark Gooding
mark.gooding at gmail.com
Thu May 11 10:04:35 EDT 2006
Hi,
I have a problem that callbacks for KeyPressEvents don't appear to
work (although it works with vtkCommand::AnyEvent). This is using MFC
and vtk. Code is below. I noticed that this has been asked before
(without answer) on the users list, so I'm pleased to see its not me
being completely dumb, but an idea of what is wrong would be nice.
Cheers,
Mark
CODE>>>>
***MyView.cpp***
vtkCallbackCommand* keyPressEvent;
static void ProcessKeyEvents( vtkObject* caller, unsigned long event,
void* clientdata, void* calldata );
***MyView.cpp***
(in constructor)
keyPressEvent = vtkCallbackCommand::New();
keyPressEvent->SetCallback( CvtkFolliclePerspectiveView::ProcessKeyEvents );
keyPressEvent->SetClientData( this );
this->pvtkRenderer->AddObserver(vtkCommand::KeyPressEvent,keyPressEvent,1.0);
(later in the file)
void CvtkFolliclePerspectiveView::ProcessKeyEvents( vtkObject* caller,
unsigned long event, void* clientdata, void* calldata ){
{
// AfxMessageBox("Key Pressed 1.\n" );
CvtkFolliclePerspectiveView* self = reinterpret_cast<
CvtkFolliclePerspectiveView*>( clientdata );
switch( event )
{
case vtkCommand::CharEvent:
AfxMessageBox("Key Pressed.\n" );
// self->DoSomeStuff();
// Prevent others from handling this event.
// self->m_vtkMouseEventCBC->SetAbortFlag(1);
break;
}
}
}
More information about the vtkusers
mailing list