Author Topic: Double clicks, dialogs and other "delayed" operations.  (Read 2469 times)

Offline azslow3

  • Administrator
  • Hero Member
  • *****
  • Posts: 1188
Double clicks, dialogs and other "delayed" operations.
« on: July 06, 2015, 01:29:16 PM »
Note: available since 0.4r1b253

Sometimes you may want execute operations after timeout. For example, you want implement double click, so once some pad is pressed and it was not pressed within 1 second second time, you execute "normal" click.

While you can arm Timer Monitor, it is not possible to perform normal actions from it directly. This limitation is more from the logic of AZ Controller then technical, it is too easy to produce hard to identify sonar freezes otherwise.

But you can use "internal MIDI loop" to produce desired effect. I attach an example preset to demonstrate how that works, the rest is the explanation for that preset.

Let say we want toggle mute of the current track on single button press and toggle solo by the same button on double press (withing 1 second).

We need one Hardware control "Btn" and associated Logical control. Also some MIDI should be assigned to this control, the example will not work otherwise (you can reassign the MIDI to some button you really have).

We also need a Software Set, "BtnState" with the following states: "Idle" (default) - there was no operations, "Single" - we want trigger single press action, "Double" - we want trigger double press action.

In the Actions list, we have:
1) "Timer once" Monitor
2) "BtnState:Idle" - trigger "Timer once" monitor in one second. That also define the time we are "waiting" for second press
3) "BtnState:Idle" - Set BtnState to Double. When we press the button second time BEFORE timer has worked, that is Double click action (it can be confusing at first, but I think you can understand the idea). That is the last thing we want to do on first press, so this action is marked "Final". That is important! We have changed BtnState to Double already. If we continue execution, "BtnState:Double" actions are going to be executed, and we do not want that (yet)
4) we do what we want, depending on the BtnState, and then reset BtnState to Idle.

In the timer:
1) we check BtnState is not Idle. After double click processing the timer is still armed, but we no longer need any action from it
2) we set BtnState to Single, there was no second click within the time
3) we send us ("loop" flag!) MIDI event which imitate our button press. Note, that you normally want value "1" (and so 127 in the configuration) for buttons, since "0" will be interpreted as "OFF".
« Last Edit: July 06, 2015, 01:32:51 PM by azslow3 »