Autofocus within editor upon button click

Say I want to have some javascript auto focus the codemirror editor view with the cursor in a particular place when the user clicks an arbitrary button. Is this possible? If so, how would I go about accomplishing it?


See here and here.