2
$\begingroup$

I am creating a product user interface mock-up, which has a series of buttons which will be navigated using a mouse. I would like to add a timer to one of the buttons to detect short and long button presses (>2 sec) of the left mouse button to set different actions accordingly.

For example:

sensor detects left mouse press > and > scene actuator sets camera to CAM1

sensor detects long mouse press > and > scene actuator sets camera to CAM2

How could I detect /differentiate between these two types of mouse click, and set the corresponding action?

I don't know how to use python, but happy to try with clear instructions : )

$\endgroup$
2
$\begingroup$

Good question! I was sure this is possible with logic bricks only. Check out the *.blend with a minimal example:

There are two actions:

  • AC_1: Turn cube by 1 Degree
  • AC_2: Turn cube by 20 Degree

The cube has a property "prop" initialized by 5, which decreased on every positive pulse when the left mouse button is pressed.

The releasing event for the left mouse button is detected by the M_RELEASE sensor and is connected to three controllers doing the following:

  • Executing AC_1 in case the property was larger than zero
  • Executing AC_2 in case the property was smaller than zero
  • Resetting the property back to 5

There should be a lean solution using Python as well. Maybe someone else has this at hand as a Plan B.

Have fun!

enter image description here

| improve this answer | |
$\endgroup$

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.