[SOLVED] Pass KeyEventArgs with MouseEventArgs

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

[SOLVED] Pass KeyEventArgs with MouseEventArgs

Postby Van » Tue Nov 03, 2009 07:03

CEGUI 0.7.1 SVN Branch

This doesn't seem to be present or we haven't figured out how to do it. We want to be able to scan for a pressed key (like shift) when the user is scrolling the mouse wheel. So far, it doesn't seem to work. We use OIS and we are receiving the SHIFT key modifier and injecting it into the CEGUI system.

Code: Select all

bool clsGUIInvList::event_SpinnerUnits_MouseWheel(const CEGUI::EventArgs& e)
{
   const CEGUI::KeyEventArgs& mKEA = static_cast<const CEGUI::KeyEventArgs&>( e );
   const CEGUI::MouseEventArgs& mMEA = static_cast<const CEGUI::MouseEventArgs&>( e );
   
   // If the user is also pressing the SHIFT key then change the spinner multiplier.
   float mMultiplier = 1.0f, mNewUnits = 0.0f;
   if ( mKEA.sysKeys == CEGUI::SystemKey::Shift ) mMultiplier = 10.0f;
   
   // Only process mouse wheel changes
   if ( mMEA.wheelChange != 0.0f )
   {
      if ( mMEA.wheelChange > 0.0f )
         mNewUnits = mSpinnerUnits->getCurrentValue() + ( mSpinnerUnits->getStepSize() * mMultiplier );
      else
         mNewUnits = mSpinnerUnits->getCurrentValue() - ( mSpinnerUnits->getStepSize() * mMultiplier );

      mSpinnerUnits->setCurrentValue( mNewUnits );
   } // wheelChange?

   return true;
} // event_SpinnerUnits_MouseWheel
Last edited by Van on Wed Nov 04, 2009 21:42, edited 1 time in total.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: [SUG] Pass KeyEventArgs with MouseEventArgs

Postby Jamarr » Tue Nov 03, 2009 19:19

The EventArgs object passed to the function does not use multiple inheritance - in other words you cannot just typecast it from one type of EventArgs to another.

Also, CEGUI does not have any support for managing the keyboard and/or mouse state. In otherwords, when you inject input that single event is fired and then forgotten about. Based on this, assuming you want to handle this through CEGUI, you would have to subscribe to EventKeyDown/EventKeyUp and check for Shift and then set your own flag appropriately. Then when EventMouseWheel is fired you'd check said flag.

To address this I suppose CEGUI could store a keyboard state map (up/down state) and make it accessible through CEGUI::System...but then you could just as easily implement the same thing yourself, setting those states at the point you inject them into CEGUI and then checking your own keyboard state map whenever you need to.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: [SOLVED] Pass KeyEventArgs with MouseEventArgs

Postby Van » Wed Nov 04, 2009 21:42

SOLVED - Implementation already exists in a different form. Great Job CE!

Actually, studying the CEGUI::MouseEventArgs class, there is already a parameter CEGUI::MouseEventArgs::sysKeys holding the current state of CEGUI::SystemKey.
Also may want to note this function: CEGUI::System::getSystemKeys()

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: [SOLVED] Pass KeyEventArgs with MouseEventArgs

Postby Jamarr » Thu Nov 05, 2009 17:36

Nice. Well now I hate you for not looking at MouseEventArgs or the System object before posting; then again, I should have looked at them myself before replying ;)
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 9 guests