Introduced new GUIEventAdatper singleton for sharing the current state between

multiple GraphicsWindows, this singleton is accessable via GUIEventEvent::getAccumulatedEventState().

Added use of this new singleton in GraphicsWindow* implementations.

Added WindowSizeHandler to osgkeyboard to help with debugging of event state
between windows.
This commit is contained in:
Robert Osfield
2007-07-13 11:17:41 +00:00
parent 03749d5e34
commit b2535d55c6
6 changed files with 26 additions and 0 deletions

View File

@@ -371,6 +371,9 @@ public:
{
#if 1
// osg::notify(osg::NOTICE)<<"Mouse "<<ea.getButtonMask()<<std::endl;
#define PRINT(mask) osg::notify(osg::NOTICE)<<#mask<<" ="<<(ea.getModKeyMask() & mask)<<std::endl;
switch(ea.getEventType())
{
@@ -423,6 +426,7 @@ int main(int , char **)
osg::ref_ptr<KeyboardModel> keyboardModel = new KeyboardModel;
viewer.addEventHandler(new osgViewer::StatsHandler);
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
viewer.addEventHandler(new KeyboardEventHandler(keyboardModel.get()));
viewer.setSceneData( keyboardModel->getScene() );

View File

@@ -254,6 +254,13 @@ public:
META_Object(osgGA, GUIEventAdapter);
/** Get the accumulated event state singleton.
* Typically all EventQueue will share this single GUIEventAdapter object for tracking
* the mouse position, keyboard and mouse masks. */
static osg::ref_ptr<GUIEventAdapter>& getAccumulatedEventState();
/** Set whether this event has been handled by an event handler or not.*/
void setHandled(bool handled) { _handled = handled; }

View File

@@ -15,6 +15,13 @@
using namespace osgGA;
osg::ref_ptr<GUIEventAdapter>& GUIEventAdapter::getAccumulatedEventState()
{
static osg::ref_ptr<GUIEventAdapter> s_eventState = new GUIEventAdapter;
return s_eventState;
}
GUIEventAdapter::GUIEventAdapter():
_handled(false),
_eventType(NONE),

View File

@@ -485,6 +485,10 @@ struct OSXCarbonWindowingSystemInterface : public osg::GraphicsContext::Windowin
void GraphicsWindowCarbon::init()
{
if (_initialized) return;
getEventQueue()->setCurrentEventState(osgGA::GUIEventAdapter::getAccumulatedEventState().get());
_windowTitleHeight = 0;
_closeRequested = false;
_ownsWindow = false;

View File

@@ -1010,6 +1010,8 @@ void GraphicsWindowWin32::init()
{
if (_initialized) return;
getEventQueue()->setCurrentEventState(osgGA::GUIEventAdapter::getAccumulatedEventState().get());
WindowData *windowData = _traits.get() ? dynamic_cast<WindowData*>(_traits->inheritedWindowData.get()) : 0;
HWND windowHandle = windowData ? windowData->_hwnd : 0;

View File

@@ -456,6 +456,8 @@ void GraphicsWindowX11::init()
return;
}
getEventQueue()->setCurrentEventState(osgGA::GUIEventAdapter::getAccumulatedEventState().get());
WindowData* inheritedWindowData = dynamic_cast<WindowData*>(_traits->inheritedWindowData.get());
_display = XOpenDisplay(_traits->displayName().c_str());