1
$\begingroup$

I would like to determine if Left Click + Shift pressed at the same time in event.type in a modal operator. I also want to treat Left Click itself as a separate event.type than one with the Shift.

I looked around and I can t seem to find an answer. I am wondering how this is done properly.

$\endgroup$
0
$\begingroup$

I may be wrong.. but this is my understanding (and it seems to work for me):

There is nothing as simultaneous with the events. Even if you press shift and click simultaneously, there are actually four separate events. 1) event.type = 'LEFT_SHIFT' with event.value = 'PRESS' 2) event.type = 'LEFTMOUSE' and event.value = 'PRESS' 3) event.type = 'LEFT_SHIFT' & event.value = 'RELEASE' 2) event.type = 'LEFTMOUSE' and event.value = 'RELEASE' (the order might change depending on what comes first).

There is also a CLICK event.value available for LEFTMOUSE event.type that combines PRESS and RELEASE.

So, to answer your question, you would basically need to store an instance variable like self.shift and set / reset its value on event.value == 'PRESS' / event.value == 'RELEASE'. You can check in your function whether with the mouse press event occurred when self.shift was True.

If you figure out a better way to do this, I would be interested to know :)

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks I will give it a try. $\endgroup$ – yarun can Sep 8 '19 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.