Unable to Detect Mouse Click
-
Hi,
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: self.Close() return True # This one does not bc = c4d.BaseContainer() if c4d.gui.GetInputState(c4d.BFM_INPUT_MOUSE,c4d.BFM_INPUT_MOUSELEFT,bc): if bc[c4d.BFM_INPUT_VALUE]==1: self.Close() return True
-
hello ,
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
def main(): bc = c4d.BaseContainer() if c4d.gui.GetInputState(c4d.BFM_INPUT_MOUSE,c4d.BFM_INPUT_MOUSELEFT,bc): if bc[c4d.BFM_INPUT_CHANNEL]== c4d.BFM_INPUT_MOUSELEFT: print "left mouse"
Cheers,
Manuel -
@m_magalhaes
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 theMOUSELEFT
. 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:
https://www.dropbox.com/s/4b8czh5w2qzt8xx/bt_popup_commands.pyp?dl=0Thank you for looking at my problem.
-
hello,
ok,
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: if self.IsOpen(): print 'left mouse close' self.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 : if self.IsOpen(): print "lost focus, close" self.Close() return c4d.gui.GeDialog.Message(self, msg, result)
Cheers,
Manuel -
@m_magalhaes
Thanks for the response. Works as expected.
I didn't know that theMessage
function can also executed commands. I thought every command should be in theCommand
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.Thanks again!
-
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.
-
hello,
Please @unti open your own thread. The context is maybe a bit different and your question is a bit different.
Cheers,
Manuel.