Keypress questions (Active window and 'If' Statements)
Hello, I am creating a patch that uses the keys of the computer keyboard in order for the user to navigate in a 3D world. I apologize if these questions were already answered, but I could not find an answer that I understood.
My first question:
How would I enable a keypress to work even if the active window isn't the patcher? Similar to this person's question: https://cycling74.com/forums/register-key-press-when-pactcher-isnt-the-active-window , but I'm not sure what's helpful in that page. I want to be able to activate keys for a 3d environment to change, but it only works so far if the patcher itself is the active window.
Second Question:
I want the user to be unable to change the environment in a certain way if a certain key hadn't been pressed prior. I have a vague idea of "if" statements, but I am unclear as to its application and would appreciate a sample patch.
For example, my patch would change if I pressed the "O" and "P" keys, but I don't want "P" to change the patch if "O" had not been pressed first.
I can post a project file of what I have so far, but it is very unorganized so far.
As far as I know, the [key] object works even if it's not on the active patcher. However it doesn't work is MAX isn't the active programme, and I wouldn't know how to go around this.
About the second question, here's one way to do it:
(if you want the key presses to be done within a specific time limit, you can use a [del] object to close the [gate] if letter "P" hasn't been pressed within n seconds, or whatever.
I am tweaking around with the patch you gave me. So far it is looking alright. Thank you.
As for my first question:
Yes, the [key] object does work but it doesn't send a bang like it would if I made the patcher window the active window. What I need is for tthe keys to register whilst the active window is the 3d render.The [key] object is only directly connected to a number box which is connected to a [sel] object.
In my Max, [key] also bangs if it's not the active window.
But in any case if the 3D render window is in Max/MSP/Jitter, then you could simply add a [key] connected to a [send lol] object on that window, and have a [receive lol] connected to a number box in your main patcher, and that should do the trick. :)
Thank you for the input, but the 3d render window isn't a kind that can be edited in that way. I will be sure to use this technique in the future though.
Here's a screen shot:
http://i.imgur.com/JXhN5T7.png
The window labelled: "myworld" is the active window that has to be eventually full-screened. :)