THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/10/2012 at 15:42, xxxxxxxx wrote:
Hey guys.
I'm still struggling with input for my tool plugin. What am trying to get is a functionality like cloning an object: you have the move tool active, you hold the CTRL key and click with the left mouse-button and drag. The mouse part I get, thanks to Yannicks great answer to my post a couple of days ago. But it seems to be impossible to get the CTRL key working. I have no problem getting keys like ESC or F1 with this code-snippet:
def KeyboardInput(self, doc, data, bd, win, msg) :
if msg.GetLong(c4d.BFM_INPUT_CHANNEL) == c4d.KEY_ESC:
print "ESC pressed"
But the qualifier-keys just won't work that way. I tried this code you can find without problem in forums:
msg[c4d.BFM_INPUT_QUALIFIER] & c4d.QCTRL:
print "CTRL pressed"
But this doesn't seems to work as the SDK says >A bitmask with the qualifiers at the time when the event occured.
So this seems only to work when you press the plugin button (which for any reasons doesn't work either, it only works with scripts for me). So the obvious question is how do I get the CTRL key (and SHIFT key for that matter) working.
And there would be a subsequent question: As I stated I want to use the control key to change the mode my tool is working like the cloning as mentioned above. So this would be done using a variable which is set while the control key is hold and reset when it's released (which is checked using a while loop) like in this code:
def KeyboardInput(self, doc, data, bd, win, msg) :
if msg.GetLong(c4d.BFM_INPUT_CHANNEL) == c4d.KEY_ESC:
print "Start ESC Pressed"
self.mode = 1 #Set Mode
while True:
bc = c4d.BaseContainer()
if gui.GetInputState(c4d.BFM_INPUT_KEYBOARD, c4d.KEY_ESC, bc) :
if bc.GetLong(c4d.BFM_INPUT_CHANNEL)==c4d.KEY_ESC:
if not bc.GetBool(c4d.BFM_INPUT_VALUE) : break
self.mode = 2 #Reset Mode
Problem is, when I click the mouse-button the keyboard loop is ended and the mode reset before the clicking of the mouse button really comes into action.
This more of a cosmetic thing, as is would also work with activating one mode by pressing the control key once and deactivate it by pressing it again, but it would be really nice to have it.
Phil