Usable Selectors for Cocoa Key Bindings

by Jacob Rus
Friday, 17 March 2006

We can use a very wide variety of selectors in our key bindings. Note, if you find more usable selectors, please let me know about them. Thanks.

Generally-applicable selectors


Text manipulation

These selectors are for inserting, selecting, deleting, and moving text.

Inserting text

In general, these selectors: “Insert a … at the insertion point or selection, deleting the selection if there is one”

Deleting text

This group of selectors simply wipes text off the face of the planet.

Killing and yanking text

These selectors delete text, but also put it onto the kill ring (which means that it can be “yanked back later”):

This one brings back text:

Change the case of the selected text

“change the case of a letter or letters in the selection, perhaps by opening a panel with capitalization options or by cycling through possible case combinations.”

“set the case of the word or words surrounding the insertion point or selection, expanding the selection if necessary”

Moving the insertion point

“move the selection or insertion point one element or character”

“move the selection or insertion point one word…”

“move the selection to… or the insertion point to…”

“scroll the receiver… one page in its scroll view, also moving the insertion point to the top of the newly displayed page.”

Scroll the text view

“scroll the receiver… in its scroll view, without changing the selection”

“scroll the selection, whatever it is, inside its visible area.”

Move the insertion point and modify the selection

“expand or reduce either end of the selection by one element or character”

“expand or reduce either end of the selection… by one whole word”

Apparently some of the options are undocumented, but work just fine

Select text


Working with marks

Other text editing options


Text Styles and formatting (mostly applies to rich text)

Set the text alignment

“applies … alignment to selected paragraphs (or all text if the receiver is a plain text object)”

“changes the base writing direction of a paragraph, for languages like Hebrew and Arabic, for example.”



Baseline, kerning, ligatures

Set the baseline of the text.

Set the kerning to be used for the text.

Tell the selection whether to use standard ligatures, or all ligatures.

Open up useful panels for text formatting

Spelling and speech

Check the spelling of the text view:

OS X Speech synthesis:

Window and document options


Closing, saving, reverting documents

These do the same as the menu options of the same name:

Window manipulations

These three simulate clicking the little gem buttons in the top left corner of the window. Note that close:, etc. are also usable selectors, but not advisable, as they act slightly differently. Most importantly, close: doesn’t prompt the user to save changes to unsaved documents, so data loss is possible if it is used:

These change window ordering or position:

This one hides the application:

Anything I can improve? Send me an email: jacobolus AT gmail