Using %modifiers with the onMousedown function
by Robert Clarke · in Torque Game Builder · 03/07/2010 (8:35 pm) · 3 replies
Hey guys,
I am trying to implement a shift-left click mouse function to select multiple objects. Its works! but it seems like the only modifier that works is left shift, which has a bite value of 1 confusingly. Right shift, ctrl don't seem to be active is this right? (the reference says otherwise).
I am trying to implement a shift-left click mouse function to select multiple objects. Its works! but it seems like the only modifier that works is left shift, which has a bite value of 1 confusingly. Right shift, ctrl don't seem to be active is this right? (the reference says otherwise).
Quote:%modifier – Mask
The modifier keys that are pressed.
* Bit 0: Left Shift
* Bit 1: Right Shift
* Bit 2: Left Control
* Bit 3: Right Control
* Bit 4: Left Alt (Windows) or Command (Mac)
* Bit 5: Right Alt (Windows) or Command (Mac)
* Bit 6: Left Option (Mac)
* Bit 7: Right Option (Mac)
#2
03/07/2010 (10:00 pm)
Also, to be complete:Global Script Varaible Code Constant Value ---------------------- ------------- ------------------------- $EventModifier::LSHIFT SI_LSHIFT (1<<0) = 1 $EventModifier::RSHIFT SI_RSHIFT (1<<1) = 2 $EventModifier::SHIFT SI_SHIFT (SI_LSHIFT|SI_RSHIFT) = 3 $EventModifier::LCTRL SI_LCTRL (1<<2) = 4 $EventModifier::RCTRL SI_RCTRL (1<<3) = 8 $EventModifier::CTRL SI_CTRL (SI_LCTRL|SI_RCTRL) = 12 $EventModifier::LALT SI_LALT (1<<4) = 16 $EventModifier::RALT SI_RALT (1<<5) = 32 $EventModifier::ALT SI_ALT (SI_LALT|SI_RALT) = 48
#3
03/08/2010 (2:51 am)
That does help thanks! The way I was echoing to the console I was only ever getting 1. Which had me suspecting that I wasn't doing it right. Cheers William.
Associate William Lee Sims
Machine Code Games
if( (%modifiers & $EventModifier::LSHIFT) || (%modifiers & $EventModifier::LCTRL) ) { ... code when left shift or left control is pressed. }There are "shortcuts" added to the system. For example, if you don't care which shift, you could write
if( (%modifiers & $EventModifier::LSHIFT) || (%modifiers & $EventModifier::RSHIFT) ) { ... } // or... even smaller if( (%modifiers & $EventModifier::SHIFT) ) { ... }Hope that helps clear it up!