Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Ctrl key pressed while LeftDown: detection.
Ctrl key pressed while LeftDown: detection. [message #27830] Thu, 05 August 2010 17:03 Go to next message
281264 is currently offline  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 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Smile

Honza

[Updated on: Thu, 05 August 2010 17:57]

Report message to a moderator

Previous Topic: EditField ctrl and StaticText ctrl in a StatusBar crtl
Next Topic: [solved]how to use upp without the ide (what is the gcc command line?)
Goto Forum:
  


Current Time: Thu Mar 28 20:21:24 CET 2024

Total time taken to generate the page: 0.00984 seconds