by jim » Thu Jan 07, 2010 9:53 am
One of the things that a lot of people struggle with when first learning QuicKeys is understanding the application is just a stand-in for the user (more or less). True, QuicKeys can do a ton of stuff but for the most part, we're just issuing commands and watching for things to happen just like the user would. This shortcut is a great example of how something that seems really difficult to do isn't anything more than a couple of copy-n-paste commands.
Step #1 is simply saving the contents of the current Clipboard to a QuicKeys variable so we can restore it later. So in case you have your life's work on the clipboard (and nowhere else), we don't destroy it by putting some quotes around text.
Step #2 issues a Command-C, a plain old copy command. This sticks whatever's highlighted on the Clipboard (and since QuicKeys watches the Clipboard for changes, we immediately have access to whatever was copied via our "Clipboard" variable)
Step #3 pastes the result of the equation ["<Clipboard Variable>"] via a mechanism that's almost identical to a Command-V. Equations that have plain text in them simply shove that text into the output they generate. So you read the equation in Step #3 as 'Concatenate a double-quote, then the value of the Clipboard variable, then another double-quote'. The action of "insert value" is what does the actual pasting back into whatever application you're working with. Since the original text is still highlighted, our paste clears that value and replaces it with the new quoted string.
Step #4 is just putting back onto the system Clipboard what we originally found there in Step #1.
Does that help clear things up?