<div>Hi guys:</div>
<div>Thanks all for your answers. It helps a lot!</div>
<div>cheers :) </div>
<div>Legeo<br></div>
<div class="gmail_quote">2009/3/10 René Molenaar <span dir="ltr"><<a href="mailto:megamillerzoid@gmail.com">megamillerzoid@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Hi,</div>
<div> </div>
<div>i use the following code to get the modifiers in.</div>
<div>call this in your mousePressEvent.</div>
<div>(and don't forget to convert the keyrelease, like other non-text key-releases)</div>
<div> </div>
<div> </div>
<div>/**<br> * Check the current event for modifiers<br> *<br> * @brief  Mouse Press Event<br> * @param event Mouse event to be placed in the event queue<br> */<br>#if USE_QT4<br>void AdapterWidget::adaptModifiers( QInputEvent* event )<br>
{<br>    int modkey = event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier);<br>    unsigned int modkeyosg = 0;<br>    if (modkey & Qt::ShiftModifier)    modkeyosg |= osgGA::GUIEventAdapter::MODKEY_SHIFT;<br>
    if (modkey & Qt::ControlModifier)  modkeyosg |= osgGA::GUIEventAdapter::MODKEY_CTRL;<br>    if (modkey & Qt::AltModifier)      modkeyosg |= osgGA::GUIEventAdapter::MODKEY_ALT;<br>    m_gw->getEventQueue()->getCurrentEventState()->setModKeyMask( modkeyosg );<br>
}<br>#else<br>void AdapterWidget::adaptModifiers( QMouseEvent* event )<br>{<br>    int modkey = event->stateAfter() & (Qt::ShiftButton | Qt::ControlButton | Qt::AltButton);<br>    unsigned int modkeyosg = 0;<br>    if (modkey & Qt::ShiftButton)    modkeyosg |= osgGA::GUIEventAdapter::MODKEY_SHIFT;<br>
    if (modkey & Qt::ControlButton)  modkeyosg |= osgGA::GUIEventAdapter::MODKEY_CTRL;<br>    if (modkey & Qt::AltButton)      modkeyosg |= osgGA::GUIEventAdapter::MODKEY_ALT;<br>    m_gw->getEventQueue()->getCurrentEventState()->setModKeyMask( modkeyosg );<br>
}<br>#endif</div>
<div> </div>
<div>Rene<br><br></div>
<div class="gmail_quote">2009/3/9 Fabien Lavignotte <span dir="ltr"><<a href="mailto:Fabien.Lavignotte@vegatechnologies.fr" target="_blank">Fabien.Lavignotte@vegatechnologies.fr</a>></span> 
<div>
<div></div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">The osgViewerQt example does not take into account modifier key. So, the<br>OSG modifier mask is always zero.<br>
I have changed the conversion between Qt event and OSG event to handle<br>modifier properly.<br>Here is my code. You can adapt this code in your widget. Let me know if<br>you need some help.<br>Fabien<br><br>/*! Helper function which converts a Qt mouse button code into a osg<br>
mouse button code */<br>inline void convertMouseEvent( osgGA::EventQueue* eventQueue,<br>QMouseEvent* eventQt, osgGA::GUIEventAdapter::EventType eventType )<br>{<br>eventQueue->getCurrentEventState()->setX( eventQt->x() );<br>
eventQueue->getCurrentEventState()->setY( eventQt->y() );<br>int button = 0;<br>switch( eventQt->button() )<br>{<br>case Qt::LeftButton :<br>button = osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON;<br>break;<br>case Qt::MidButton :<br>
button = osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON;<br>break;<br>case Qt::RightButton :<br>button = osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON;<br>break;<br>}<br>if ( eventQt->type() == QEvent::MouseButtonPress )<br>
eventQueue->getCurrentEventState()->setButtonMask( button |<br>eventQueue->getCurrentEventState()->getButtonMask());<br>else<br>eventQueue->getCurrentEventState()->setButtonMask( ~button &<br>eventQueue->getCurrentEventState()->getButtonMask());<br>
unsigned int modKeyMask = 0;<br>if( eventQt->modifiers() & Qt::ShiftModifier)<br>{<br>modKeyMask |= osgGA::GUIEventAdapter::MODKEY_SHIFT;<br>}<br>if( eventQt->modifiers() & Qt::ControlModifier)<br>{<br>modKeyMask |= osgGA::GUIEventAdapter::MODKEY_CTRL;<br>
}<br>if( eventQt->modifiers() & Qt::AltModifier)<br>{<br>modKeyMask |= osgGA::GUIEventAdapter::MODKEY_ALT;<br>}<br>osgGA::GUIEventAdapter* event = eventQueue->createEvent();<br>event->setEventType(eventType);<br>
event->setTime(eventQueue->getTime());<br>event->setModKeyMask(modKeyMask);<br>event->setButton(button);<br>eventQueue->addEvent(event);<br>}<br><br>/*! overwrites the mouse pressed handler */<br><br>void Viewer::mousePressEvent( QMouseEvent* event )<br>
{<br>       GLWidget::mousePressEvent(event);<br>       if ( _graphicsWindow.valid() )<br>       {<br>               convertMouseEvent( _graphicsWindow->getEventQueue(),<br>event, osgGA::GUIEventAdapter::PUSH );<br>       }<br>
}<br><br>/*! overwrites the mouse released handler */<br>void Viewer::mouseReleaseEvent( QMouseEvent* event )<br>{<br>       GLWidget::mousePressEvent(event);<br>       if ( _graphicsWindow.valid() )<br>       {<br>               convertMouseEvent( _graphicsWindow->getEventQueue(),<br>
event, osgGA::GUIEventAdapter::RELEASE );<br>       }<br>}<br><br><br>________________________________<br>
<div><br>From: <a href="mailto:osg-users-bounces@lists.openscenegraph.org" target="_blank">osg-users-bounces@lists.openscenegraph.org</a><br></div>[mailto:<a href="mailto:osg-users-bounces@lists.openscenegraph.org" target="_blank">osg-users-bounces@lists.openscenegraph.org</a>] On Behalf Of Dieter<br>
Pfeffer<br>Sent: lundi 9 mars 2009 09:34<br>To: OpenSceneGraph Users<br>Subject: Re: [osg-users] osg+QT MODKEY How to<br>
<div>
<div></div>
<div><br><br>Hi Legeo<br><br>I had a similar problem - using osg, qt4 and the AdapterWidget example.<br><br>In AdapterWidget::keypressEvent (...)<br>osgGA::GUIEventAdapter::KeySymbol) * (event->text().toAscii().data()<br>
returns 0 in the call<br>_gw->getEventQueue()->keyPress( (... ) )  for keys like:<br><br>Qt::Key_up ... Have a look at the Qt documentation Qt::Key.<br><br>I have managed it with:<br><br>int c = *event->text().toAscii().data();<br>
<br>if ( c == 0)<br><br>{<br><br>switch (event->key())<br><br>{<br><br>case Qt::Key_PageDown:<br><br>_gw->getEventQueue()->keyPress(<br>osgGA::GUIEventAdapter::KeySymbol::KEY_Page_Down );<br><br>break;<br><br>case Qt::Key_PageUp:<br>
<br>_gw->getEventQueue()->keyPress(<br>osgGA::GUIEventAdapter::KeySymbol::KEY_Page_Up );<br><br>break;<br><br>case Qt::Key_Up:<br><br>_gw->getEventQueue()->keyPress( osgGA::GUIEventAdapter::KEY_Up);<br><br>break;<br>
<br>}<br><br>}<br>else<br>_gw->getEventQueue()->keyPress( (osgGA::GUIEventAdapter::KeySymbol) *<br>(event->text().toAscii().data() ) );<br><br>There might be a better solution but it works.<br><br>Dieter<br><br><br>
<br><br>Unclassified Mail<br><br><br>       -----Original Message-----<br>       From: <a href="mailto:osg-users-bounces@lists.openscenegraph.org" target="_blank">osg-users-bounces@lists.openscenegraph.org</a><br>[mailto:<a href="mailto:osg-users-bounces@lists.openscenegraph.org" target="_blank">osg-users-bounces@lists.openscenegraph.org</a>]On Behalf Of<br>
legeochen<br>       Sent: Saturday, 07 March, 2009 09:14<br>       To: OpenSceneGraph Users<br>       Subject: [osg-users] osg+QT MODKEY How to<br><br><br>       Hi all,<br>          I'm trying to add a Modkey event handler to my application<br>
with osg and qt4. But it seems that the getModKeyMask() fuction fails to<br>work. Return value of getModKeyMask() always is 0, even if I have a<br>MODKEY pressed. And, this is my code:<br>               if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH<br>
&&<br>                    ea.getButtonMask() ==<br>osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON &&<br>                    ea.getModKeyMask() ==<br>osgGA::GUIEventAdapter::MODKEY_SHIFT )<br>                {<br>
                   /*---------------------------------------------<br>                           do something here<br>                   -------------------------------------------------*/<br>               }<br>       How can I handle it? Thanks in advance!<br>
<br>       cheers<br>       legeo<br><br><br><br>------------------------------------------------------------------------<br>------------------------------------<br>Disclaimer:<br><br>If you are not the intended recipient of this email, please notify the<br>
sender and delete it.<br>Any unauthorized copying, disclosure or distribution of this email or<br>its attachment(s) is forbidden.<br>Thales Nederland BV will not accept liability for any damage caused by<br>this email or its attachment(s).<br>
Thales Nederland BV is seated in Hengelo and is registered at the<br>Chamber of Commerce under number 06061578.<br>------------------------------------------------------------------------<br>------------------------------------<br>
<br><br><br></div></div>______________________________________________________________________<br>This email has been scanned by the MessageLabs Email Security System.<br>For more information please visit <a href="http://www.messagelabs.com/email" target="_blank">http://www.messagelabs.com/email</a><br>
______________________________________________________________________<br><br><br>______________________________________________________________________<br>This email has been scanned by the MessageLabs Email Security System.<br>
For more information please visit <a href="http://www.messagelabs.com/email" target="_blank">http://www.messagelabs.com/email</a><br>______________________________________________________________________<br>
<div>
<div></div>
<div>_______________________________________________<br>osg-users mailing list<br><a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br><a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</div></div></blockquote></div></div></div><br><br>_______________________________________________<br>osg-users mailing list<br><a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br><br></blockquote></div><br>