I have this edited code snippet from Cineversity. The example is using keyboard but I'm trying to access the mouse click. Should I have additional settings for the mouse inputs? Thank you for looking at my problem.
# This one works
if id in all_button_ids:
# This one does not
bc = c4d.BaseContainer()
In what context are you using this function ?
you can have information on this manual talking about Mouse and Keyboard Interaction
You also have the liquid tool that show how to check the mouse input.
Something like this should work
bc = c4d.BaseContainer()
if bc[c4d.BFM_INPUT_CHANNEL]== c4d.BFM_INPUT_MOUSELEFT:
print "left mouse"
Thanks for the response.
RE: In what context are you using this function ?
I'm trying to create pop-up dialog. I want it to close when I click a command. That's figured it out.
I also want it to close if I just click somewhere that's not a button hence the MOUSELEFT. That's the part I am having a problem with.
RE: Something like this should work
Apparently, it doesn't detect the mouse click still.
I also tried the if msg[c4d.BFM_INPUT_CHANNEL]==c4d.BFM_INPUT_MOUSELEFT from the liquid tool. And it does not seem to detect it.
You can see the current code here:
Thank you for looking at my problem.
something like this seem to work. Let me know.
Be aware that the right click is catched for the popmenu that doesn't seem to send any INPUT message to the DialogBox.
def Message(self, msg, result):
theID = msg.GetId()
if theID == c4d.BFM_INPUT:
if msg[c4d.BFM_INPUT_DEVICE] == c4d.BFM_INPUT_MOUSE:
if msg[c4d.BFM_INPUT_CHANNEL] == c4d.BFM_INPUT_MOUSELEFT:
print 'left mouse close'
elif msg[c4d.BFM_INPUT_CHANNEL] == c4d.BFM_INPUT_MOUSEMIDDLE:
print 'middle mouse'
elif msg[c4d.BFM_INPUT_CHANNEL] == c4d.BFM_INPUT_MOUSERIGHT:
print "right mouse"
elif theID == c4d.BFM_LOSTFOCUS :
print "lost focus, close"
return c4d.gui.GeDialog.Message(self, msg, result)
Thanks for the response. Works as expected.
I didn't know that the Message function can also executed commands. I thought every command should be in the Command function.
RE: Be aware that the right click is catched for the popmenu
No worries. I don't use the RMB for my code so far.
Can I modify this code to 'catch' the right or middleclick in the viewport / editor befor it is doing the internal function?
I was trying to get the middleclick in the editor and I can detect it, but it will always switch between four-split and one window editor layout. - I don't want this to happen.
Please @unti open your own thread. The context is maybe a bit different and your question is a bit different.