Home » Community » Newbie corner » Ctrl key pressed while LeftDown: detection.
Ctrl key pressed while LeftDown: detection. [message #27830] |
Thu, 05 August 2010 17:03 |
281264
Messages: 270 Registered: June 2010 Location: Spain
|
Experienced Member |
|
|
Hi,
A simple query: how can I detect that the “control” key is pressed when the left button of the mouse is pressed? I see the parameter dword keyflag in LeftDown function, but what are the combinations of keyflags for Shift, Ctrl and Alt?
Cheers,
Javier
|
|
|
Re: Ctrl key pressed while LeftDown: detection. [message #27831 is a reply to message #27830] |
Thu, 05 August 2010 17:57 |
|
281264 wrote on Thu, 05 August 2010 17:03 | Hi,
A simple query: how can I detect that the “control” key is pressed when the left button of the mouse is pressed? I see the parameter dword keyflag in LeftDown function, but what are the combinations of keyflags for Shift, Ctrl and Alt?
Cheers,
Javier
|
Hi Javier,
Simple answer: Each bit in keyflag stands for one action (not necessarily key press). The easiest way to check what is pressed is using the K_* enums defined in CtrlCore:enum {
K_DELTA = 0x010000,
K_ALT = 0x080000,
K_SHIFT = 0x040000,
K_CTRL = 0x020000,
K_KEYUP = 0x100000,
K_MOUSEMIDDLE = 0x200000,
K_MOUSERIGHT = 0x400000,
K_MOUSELEFT = 0x800000,
K_MOUSEDOUBLE = 0x1000000,
K_MOUSETRIPLE = 0x2000000,
K_SHIFT_CTRL = K_SHIFT|K_CTRL,
};
So to check if alt and shift are pressed you would do keyflags&(K_ALT|K_SHIFT) etc.
More generally, there are bool GetShift(), GetCtrl(), GetAlt(), GetCapsLock() and GetMouse*() functions, which can be used to query the keys and mousebuttons anywhere in the code. Those are not used much. Incidentally, I just found them yesterday
Honza
[Updated on: Thu, 05 August 2010 17:57] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon May 13 09:58:52 CEST 2024
Total time taken to generate the page: 0.02723 seconds
|