Mouse event and key event together ? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
krishnaprasad
Experienced Solver
Experienced Solver
Posts: 77
Joined: Tue Oct 21, 2008 6:07 pm

Mouse event and key event together ?

Post by krishnaprasad »

Is there a way i can see if a key has been pressed and then set a flag using which the mouse event is called ? I would need to see if spacebar is pressed and if yes, i would need to change the cursor and call a panning function
timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg »

Couldn't you set the flag in a KEY_DOWN event and clear it in a KEY_UP event?
framepointer
Super wx Problem Solver
Super wx Problem Solver
Posts: 264
Joined: Mon Aug 07, 2006 3:25 pm
Location: Baia Mare, Romania
Contact:

Post by framepointer »

Hi.

You can use EVT_KEY_DOWN and EVT_KEY_UP.
In the key down event set a boolean value to true if the key is SPACE. In the key up event unset the boolean value if the key is SPACE.

In the mouse event just check for this boolean value. Of course, the devs could add an array which could hold the keys currently pressed :D

Also, since the events are called in order, if you hold down space and click, you will be able to determine it exactly.

Regards
Software is like sex,
It's better when it's free.
~Linus Torvalds
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,

I'm not sure whether you want to check the mouse state in a key-event, or vice versa. But you can use one of http://docs.wxwidgets.org/stable/wx_mis ... mousestate and http://docs.wxwidgets.org/stable/wx_mis ... etkeystate

Regards,

David
Post Reply