Пример #1
0
bool InputEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*) 
{ 
	osgViewer::View* const view = dynamic_cast<osgViewer::View*>(&aa);
	if (view && view->getViewerBase()) {
		osgGA::GUIEventAdapter::EventType eventType = ea.getEventType();
		switch (eventType) 
		{
			case osgGA::GUIEventAdapter::KEYDOWN:
			{
				KeyDown(ea, aa);
				break;
			}
			case osgGA::GUIEventAdapter::KEYUP:
			{
				KeyUp(ea, aa);
				break;
			}

			case osgGA::GUIEventAdapter::DRAG:
			case osgGA::GUIEventAdapter::MOVE:
			{
				MouseMove(ea, aa);
				break;
			}

			case osgGA::GUIEventAdapter::PUSH:
			{
				MouseButtonDown(ea, aa);
				break;
			}

			case osgGA::GUIEventAdapter::RELEASE:
			{
				MouseButtonRelease(ea, aa);
				break;
			}

			case osgGA::GUIEventAdapter::FRAME:
			{
				m_frameCount ++;
				break;
			}

			case osgGA::GUIEventAdapter::CLOSE_WINDOW:
			case osgGA::GUIEventAdapter::QUIT_APPLICATION:
			{
				m_applicationTerminated = true;
				break;
			}

			default:
				break;
		}
	}

	return false;
}
Пример #2
0
    /*!
        \fn wcurses::Application::ProcessMouseEvent( MouseEvent* M )
     */
    bool Application::ProcessMouseEvent ( MouseEvent* M )
    {
        Debug << M->ToString().std();
        _curTarget=QueryTarget ( M );
        if(!_curTarget){
            Dbg << "error: could not get target widget!!"; DEND;
            return false;
        }

        if ( M->What() == event::MouseButtonClick ) return MouseButtonClick ( M );
        if ( M->What() == event::MouseButtonPress ) return MouseButtonPress ( M );
        if ( M->What() == event::MouseButtonDblClick ) return MouseButtonDblClick ( M );
        if ( M->What() == event::MouseButtonRelease ) return MouseButtonRelease ( M );
        //if ( M->What() == event::MouseButtonMove ) return MouseButton( M );
        Dbg << "Error: unknow  mouse event!!" << M->ToString().std();
        DEND;

        return false;
    }