Hi there! I just started to learn Pure Data. Does anyone know how to realize the function of key and keyup but for a virtual button like at the picture (e.g. bng)? Here the signal goes while the mechanical button is helding, but I would like to know how to do it with the virtual one. Thanks a lot in advance!
Something like key & keyup for virtual button
@ActPk The difficulty is that if a key is pressed, the OS will send several keyup and keydown events. This is the reason for that if you press and hold a key in a text editor, it will print the symbol of that key multible times, like: ffffffffffffffffffffffffffffffffffffffffffffff.
So in this example, the keydown event will immediately send a one, but if the [keyname] object sends a zero, it will start a delay of 50 milliseconds. If within this time another one is sent out, the delay will be stopped. Only if no other one is sent, the delay will finish and send a zero.
So this works, but the keyup event will have a delay of 50 milliseconds. I am not sure if this can be prevented as the behavior is due to the OS. It may be neccessary to use another delay time on your OS to make it work.
@ActPk So my answer was for a real button, not for a virtual one...
For a virtual one you will need an extension like [mousestate], because in vanilla there is no way to detect a mouseup event. So you would have do use some object that detects mousedown and mouseup and check if the mouse is within given coordinates to simulate this kind of behavior.
@ingox The OP is looking to be able to click-hold (mouse) so that he can use that when running a patch in Android.
I didn't know that when I posted the patch he has shown, and I can't think of a way to do that in Pd.
It will be unpredictable too, when run in Android, even if there is a solution.
So I imagine it needs to be Vanilla as well.
I don't know of any way to do this with a mouse, as mouse events only work in editmode..
I wonder if there is a special object for Android though in Droid Party or.....?
P.S just seen your post......