forked from jrus/cocoa-text-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectors.html
558 lines (446 loc) · 20.4 KB
/
selectors.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Cocoa Text System - Usable Selectors</title>
<style type="text/css">
/* CSS hacked together by Jacob Rus */
body {
margin:0;
background-color: #ccf;
padding-left:5%;
padding-top:1.5em;
padding-bottom:3em;
font-family: "Helvetica", sans-serif;
}
#contents {
background-color: #FAFFF2;
border: .25em #99C solid;
width: 80%;
max-width: 40em;
min-width: 20em;
padding-left:2.5em;
padding-right:3em;
margin:0;
}
#email{
font-size:80%;
width: 80%;
max-width: 40em;
min-width: 20em;
padding-top:.5em;
padding-left:30%;
margin:0;
float: left;
}
a:link {
color: #45B;
}
h1 {
color: #337;
margin-left:-.7em;
}
h2 {
color: #337;
margin-left:-.5em;
}
h3 {
color: #337;
}
h4 {
color: #337;
}
blockquote {
margin-left:2em;
}
pre {
margin-left:1.5em;
margin-right:-1em;
padding: .5em;
border: 1px #99C dashed;
background-color: #eef;
}
code {
font-family: "Monaco", "ProFont", "Bitstream Vera Sans Mono", "Andale Sans Mono", "Consolas", monospace;
color: #920;
}
}</style>
</head><body>
<div id="contents">
<h1 id="usable_selectors_for_cocoa_key_bindings">Usable Selectors for Cocoa Key Bindings</h1>
<p>by Jacob Rus <br />
Friday, 17 March 2006</p>
<p>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.</p>
<h2 id="generally_applicable_selectors">Generally-applicable selectors</h2>
<ul>
<li><p><code>cancelOperation:</code> — “cancel the current operation.”</p></li>
<li><p><code>showContextHelp:</code> — “invoke the help system, displaying information
relevant to the receiver and its current state. The sender argument is
typically the object that invoked this method.”</p></li>
</ul>
<h3 id="undo_redo">Undo/redo</h3>
<ul>
<li><code>undo:</code></li>
<li><p><code>redo:</code></p></li>
<li><p><code>breakUndoCoalescing</code> — this one sets up an undo state. So if some more
text is typed, and then undo is invoked, it will come back to this point.</p></li>
</ul>
<h2 id="text_manipulation">Text manipulation</h2>
<p>These selectors are for inserting, selecting, deleting, and moving text.</p>
<h3 id="inserting_text">Inserting text</h3>
<p>In general, these selectors: “Insert a … at the insertion point or selection, deleting the selection if there is one”</p>
<ul>
<li><p>These two also “end editing if the receiver is a text field”</p>
<ul>
<li><code>insertTab:</code></li>
<li><code>insertNewline:</code></li>
</ul></li>
<li><p>These selectors should be used to avoid tabbing out of, for instance, a
form field</p>
<ul>
<li><code>insertTabIgnoringFieldEditor:</code></li>
<li><code>insertNewlineIgnoringFieldEditor:</code></li>
</ul></li>
<li><p><code>insertLineBreak:</code></p></li>
<li><code>insertParagraphSeparator:</code></li>
<li><p><code>insertContainerBreak:</code></p></li>
<li><p><code>insertBacktab:</code> — “handle a ‘backward tab’”</p></li>
<li><p><code>insertText:</code> — my favorite selector, “insert a string at the insertion
point or selection, deleting the selection if there is one.”</p></li>
</ul>
<h3 id="deleting_text">Deleting text</h3>
<p>This group of selectors simply wipes text off the face of the planet.</p>
<ul>
<li><p><code>delete:</code> — “deletes the selected text only”</p></li>
<li><p><code>deleteBackward:</code> </p></li>
<li><code>deleteForward:</code></li>
<li><code>deleteWordBackward:</code> </li>
<li><p><code>deleteWordForward:</code></p></li>
<li><p><code>deleteBackwardByDecomposingPreviousCharacter:</code> — “If the previous
character is canonically decomposable, try to delete only the last
character in the grapheme cluster (for example, deleting “a”+ “´” results
in “a”)”</p></li>
</ul>
<h3 id="killing_and_yanking_text">Killing and yanking text</h3>
<p>These selectors delete text, but also put it onto the kill ring (which means that it can be “yanked back later”):</p>
<ul>
<li><code>deleteToBeginningOfLine:</code> </li>
<li><p><code>deleteToEndOfLine:</code></p></li>
<li><p><code>deleteToBeginningOfParagraph:</code> </p></li>
<li><p><code>deleteToEndOfParagraph:</code></p></li>
<li><p><code>deleteToMark:</code> — “Delete all items from the insertion point to a
previously placed mark, including the selection itself if not empty.”</p></li>
</ul>
<p>This one brings back text:</p>
<ul>
<li><code>yank:</code> — “Replaces the insertion point or selection with text from the
kill buffer.”</li>
</ul>
<h3 id="change_the_case_of_the_selected_text">Change the case of the selected text</h3>
<p>“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.”</p>
<ul>
<li><code>changeCaseOfLetter:</code></li>
</ul>
<p>“set the case of the word or words surrounding the insertion point or
selection, expanding the selection if necessary”</p>
<ul>
<li><code>lowercaseWord:</code></li>
<li><code>uppercaseWord:</code></li>
<li><code>capitalizeWord:</code></li>
</ul>
<h3 id="moving_the_insertion_point">Moving the insertion point</h3>
<p>“move the selection or insertion point one element or character”</p>
<ul>
<li><code>moveBackward:</code> </li>
<li><code>moveForward:</code></li>
<li><code>moveLeft:</code> </li>
<li><code>moveRight:</code></li>
<li><code>moveUp:</code></li>
<li><code>moveDown:</code></li>
</ul>
<p>“move the selection or insertion point one word…”</p>
<ul>
<li><code>moveWordBackward:</code></li>
<li><code>moveWordForward:</code></li>
<li><code>moveWordLeft:</code></li>
<li><code>moveWordRight:</code></li>
</ul>
<p>“move the selection to… or the insertion point to…”</p>
<ul>
<li><code>moveToBeginningOfLine:</code></li>
<li><code>moveToEndOfLine:</code></li>
<li><code>moveToBeginningOfParagraph:</code></li>
<li><code>moveToEndOfParagraph:</code></li>
<li><code>moveToBeginningOfDocument:</code></li>
<li><code>moveToEndOfDocument:</code></li>
</ul>
<p>“scroll the receiver… one page in its scroll view, also moving the insertion
point to the top of the newly displayed page.”</p>
<ul>
<li><code>pageUp:</code></li>
<li><code>pageDown:</code></li>
</ul>
<h3 id="scroll_the_text_view">Scroll the text view</h3>
<p>“scroll the receiver… in its scroll view, without changing the selection”</p>
<ul>
<li><code>scrollLineUp:</code></li>
<li><code>scrollLineDown:</code></li>
<li><code>scrollPageUp:</code></li>
<li><code>scrollPageDown:</code></li>
</ul>
<p>“scroll the selection, whatever it is, inside its visible area.”</p>
<ul>
<li><code>centerSelectionInVisibleArea:</code></li>
</ul>
<h3 id="move_the_insertion_point_and_modify_the_selection">Move the insertion point and modify the selection</h3>
<p>“expand or reduce either end of the selection by one element or character”</p>
<ul>
<li><code>moveBackwardAndModifySelection:</code></li>
<li><code>moveForwardAndModifySelection:</code></li>
<li><code>moveLeftAndModifySelection:</code></li>
<li><code>moveRightAndModifySelection:</code></li>
<li><code>moveUpAndModifySelection:</code></li>
<li><code>moveDownAndModifySelection:</code></li>
</ul>
<p>“expand or reduce either end of the selection… by one whole word”</p>
<ul>
<li><code>moveWordBackwardAndModifySelection:</code></li>
<li><code>moveWordForwardAndModifySelection:</code></li>
<li><code>moveWordLeftAndModifySelection:</code></li>
<li><code>moveWordRightAndModifySelection:</code></li>
</ul>
<p>Apparently some of the options are undocumented, but work just fine</p>
<ul>
<li><code>moveToBeginningOfDocumentAndModifySelection:</code></li>
<li><code>moveToEndOfDocumentAndModifySelection:</code></li>
<li><code>moveToBeginningOfLineAndModifySelection:</code></li>
<li><code>moveToEndOfLineAndModifySelection:</code></li>
<li><code>moveToBeginningOfParagraphAndModifySelection:</code></li>
<li><code>moveToEndOfParagraphAndModifySelection:</code></li>
<li><code>pageUpAndModifySelection:</code></li>
<li><code>pageDownAndModifySelection:</code></li>
</ul>
<h3 id="select_text">Select text</h3>
<p>“select…”</p>
<ul>
<li><code>selectAll:</code></li>
<li><code>selectLine:</code></li>
<li><code>selectParagraph:</code></li>
<li><code>selectWord:</code> — “extend the selection to the nearest word boundaries
outside it (up to, but not including, word delimiters).”</li>
<li><code>selectToMark:</code> — “select all items from the insertion point or selection
to a previously placed mark, including the selection itself if not empty.”</li>
</ul>
<h3 id="working_with_marks">Working with marks</h3>
<ul>
<li><p><code>setMark:</code> — “set a mark at the insertion point or selection, which is
used by deleteToMark: and selectToMark:”</p></li>
<li><p><code>swapWithMark:</code> — “swap the mark and the selection or insertion point, so
that what was marked is now the selection or insertion point, and what was
the insertion point or selection is now the mark.”</p></li>
<li><p><code>selectToMark:</code> — “select all items from the insertion point or selection
to a previously placed mark, including the selection itself if not empty.”</p></li>
<li><p><code>deleteToMark:</code> — “delete all items from the insertion point to a
previously placed mark, including the selection itself if not empty.”</p></li>
</ul>
<h3 id="other_text_editing_options">Other text editing options</h3>
<ul>
<li><p><code>complete:</code> — “complete an operation in progress or a partially
constructed element.”</p></li>
<li><p><code>indent:</code> — “indent the selection or the insertion point if there is no
selection.”</p></li>
<li><p><code>transpose:</code> — “Transposes the characters to either side of the insertion
point and advances the insertion point past both of them. Does nothing to
a selected range of text.”</p></li>
<li><p><code>transposeWords:</code> — “Transposes the words to either side of the insertion
point and advances the insertion point past both of them. Does nothing to
a selected range of text.”</p></li>
</ul>
<h3 id="cut_copy_paste">Cut/Copy/Paste</h3>
<ul>
<li><p><code>copy:</code> — “copies the selected text onto the general pasteboard, in as
many formats as the receiver supports.”</p></li>
<li><p><code>cut:</code> — “deletes the selected text and places it onto the general
pasteboard, in as many formats as the receiver supports.”</p></li>
<li><p><code>paste:</code> — “pastes text from the general pasteboard at the insertion
point or over the selection.”</p></li>
<li><p><code>pasteAsPlainText:</code> — “inserts the contents of the pasteboard into the
receiver’s text as plain text, in the manner of insertText:.”</p></li>
<li><p><code>pasteAsRichText:</code> — “inserts the contents of the pasteboard into the
receiver’s text as rich text, maintaining its attributes.”</p></li>
<li><p>Copy/paste fonts:</p>
<ul>
<li><p><code>copyFont:</code> — “copies the font information for the first character of
the selection (or for the insertion point) onto the font pasteboard,
as NSFontPboardType.”</p></li>
<li><p><code>pasteFont:</code> — “pastes font information from the font pasteboard onto
the selected text or insertion point of a rich text object, or over
all text of a plain text object.”</p></li>
</ul></li>
<li><p>Copy/paste ruler:</p>
<ul>
<li><p><code>copyRuler:</code> — “copies the paragraph style information for first
selected paragraph onto the ruler pasteboard, as NSRulerPboardType,
and expands the selection to paragraph boundaries.”</p></li>
<li><p><code>pasteRuler:</code> — “pastes paragraph style information from the ruler
pasteboard onto the selected paragraphs of a rich text object.”</p></li>
</ul></li>
</ul>
<h2 id="text_styles_and_formatting_mostly_applies_to_rich_text">Text Styles and formatting (mostly applies to rich text)</h2>
<h3 id="set_the_text_alignment">Set the text alignment</h3>
<p>“applies … alignment to selected paragraphs (or all text if the receiver is
a plain text object)”</p>
<ul>
<li><code>alignCenter:</code></li>
<li><code>alignLeft:</code></li>
<li><code>alignRight:</code></li>
<li><code>alignJustified:</code></li>
</ul>
<p>“changes the base writing direction of a paragraph, for languages like Hebrew
and Arabic, for example.”</p>
<ul>
<li><code>toggleBaseWritingDirection:</code></li>
<li><code>changeBaseWritingDirectionToRTL:</code></li>
<li><code>changeBaseWritingDirectionToLTR:</code></li>
</ul>
<h3 id="superscript_subscript">Superscript/subscript</h3>
<ul>
<li><p><code>superscript:</code> — “applies a superscript attribute to selected text (or
all text if the receiver is a plain text object), raising its baseline
offset by a predefined amount.”</p></li>
<li><p><code>subscript:</code> — “applies a subscript attribute to selected text (or all
text if the receiver is a plain text object), lowering its baseline offset
by a predefined amount.”</p></li>
<li><p><code>unscript:</code> — “removes any superscripting or subscripting from selected
text (or all text if the receiver is a plain text object).”</p></li>
</ul>
<h3 id="underline_outline">Underline/outline</h3>
<ul>
<li><p><code>underline:</code> — “underlines selected text for a rich text object, or all
text for a plain text object.”</p></li>
<li><p><code>outline:</code></p></li>
</ul>
<h3 id="baseline_kerning_ligatures">Baseline, kerning, ligatures</h3>
<p>Set the baseline of the text.</p>
<ul>
<li><p><code>lowerBaseline:</code> — “lowers the baseline offset of selected text by 1 point,
or of all text if the receiver is a plain text view.”</p></li>
<li><p><code>raiseBaseline:</code> — “raises the baseline offset of selected text by 1 point,
or of all text if the receiver is a plain text view.”</p></li>
</ul>
<p>Set the kerning to be used for the text.</p>
<ul>
<li><p><code>useStandardKerning:</code> — “cause the receiver to use pair kerning data for
the glyphs in its selection, or for all glyphs if the receiver is a plain
text view.”</p></li>
<li><p><code>turnOffKerning:</code> — “cause the receiver to use nominal glyph spacing for
the glyphs in its selection, or for all glyphs if the receiver is a plain
text view.”</p></li>
<li><p><code>loosenKerning:</code> — “increase the space between glyphs in the receiver’s
selection, or in all text if the receiver is a plain text view.”</p></li>
<li><p><code>tightenKerning:</code> — “decrease the space between glyphs in the receiver’s
selection, or for all glyphs if the receiver is a plain text view.”</p></li>
</ul>
<p>Tell the selection whether to use standard ligatures, or all ligatures.</p>
<ul>
<li><p><code>useStandardLigatures:</code> — “cause the receiver to use the standard
ligatures available for the fonts and languages used when setting text,
for the glyphs in the selection if the receiver is a rich text view, or
for all glyphs if it’s a plain text view.”</p></li>
<li><p><code>turnOffLigatures:</code> — “cause the receiver to use only required ligatures
when setting text, for the glyphs in the selection if the receiver is a
rich text view, or for all glyphs if it’s a plain text view.”</p></li>
<li><p><code>useAllLigatures:</code> — “cause the receiver to use all ligatures available
for the fonts and languages used when setting text, for the glyphs in the
selection if the receiver is a rich text view, or for all glyphs if it’s a
plain text view.”</p></li>
<li><p><code>toggleTraditionalCharacterShape:</code> — “toggle the
NSCharacterShapeAttibuteName attribute at the current selection.”</p></li>
</ul>
<h3 id="open_up_useful_panels_for_text_formatting">Open up useful panels for text formatting</h3>
<ul>
<li><p><code>orderFrontLinkPanel:</code> — “bring forward a panel allowing the user to
manipulate links in the text view.”</p></li>
<li><p><code>orderFrontListPanel:</code> — “bring forward a panel allowing the user to
manipulate text lists in the text view.”</p></li>
<li><p><code>orderFrontSpacingPanel:</code> — “bring forward a panel allowing the user to
manipulate text line heights, interline spacing, and paragraph spacing, in
the text view.</p></li>
<li><p><code>orderFrontTablePanel:</code> — “bring forward a panel allowing the user to
manipulate text tables in the text view.”</p></li>
</ul>
<h2 id="spelling_and_speech">Spelling and speech</h2>
<p>Check the spelling of the text view:</p>
<ul>
<li><p><code>toggleContinuousSpellChecking:</code> — “toggle whether continuous spell
checking is enabled for the receiver.”</p></li>
<li><p>Perform spell checking. If I remember, the first one of these simply
selects a misspelled word. The second one opens the spelling panel, and
the third one tells the spelling system to ignore the selected word. I’m
not positive of that however.</p>
<ul>
<li><p><code>checkSpelling:</code> — “search for a misspelled word in the receiver’s
text.”</p></li>
<li><p><code>showGuessPanel:</code> — “open the Spelling panel, allowing the user to
make a correction during spell checking.”</p></li>
<li><p><code>ignoreSpelling:</code></p></li>
</ul></li>
</ul>
<p>OS X Speech synthesis:</p>
<ul>
<li><p><code>startSpeaking:</code> — “speak the selected text, or all text if no
selection.”</p></li>
<li><p><code>stopSpeaking:</code> — “stop the speaking of text.”</p></li>
</ul>
<h2 id="window_and_document_options">Window and document options</h2>
<h3 id="printing">Printing</h3>
<ul>
<li><p><code>printDocument:</code> — “bring up print sheet”</p></li>
<li><p><code>runPageLayout:</code> — the same thing happens as when the user chooses the
Page Setup menu command.</p></li>
</ul>
<h3 id="closing_saving_reverting_documents">Closing, saving, reverting documents</h3>
<p>These do the same as the menu options of the same name:</p>
<ul>
<li><p><code>save:</code></p></li>
<li><p><code>saveAs:</code></p></li>
<li><p><code>saveTo:</code></p></li>
<li><p><code>revert:</code></p></li>
<li><p><code>performClose:</code> — “simulate the user clicking the close button by
momentarily highlighting the button and then closing the window.”</p></li>
</ul>
<!--
* `new:`
* `openDocument:`
* `saveAllDocuments:`
* `clearRecentDocuments:` - "empty the recent documents list for the
application."
-->
<h3 id="window_manipulations">Window manipulations</h3>
<p>These three simulate clicking the little gem buttons in the top left corner of
the window. Note that <code>close:</code>, etc. are also usable selectors, but not
advisable, as they act slightly differently. Most importantly, <code>close:</code>
doesn’t prompt the user to save changes to unsaved documents, so data loss is
possible if it is used:</p>
<ul>
<li><code>performClose:</code></li>
<li><code>performMiniaturize:</code></li>
<li><code>performZoom:</code></li>
</ul>
<p>These change window ordering or position:</p>
<ul>
<li><p><code>center</code> — “set the window’s location to the center of the screen.”</p></li>
<li><p><code>orderBack:</code> — move the window behind all the other windows, without
changing either the key window or the main window.</p></li>
<li><p><code>orderFront:</code> — move the window in front of all the other windows,
without changing either the key window or the main window.</p></li>
</ul>
<p>This one hides the application:</p>
<ul>
<li><code>hide:</code> — “Hide all the application’s windows, and the next application
in line is activated.”</li>
</ul>
</div>
<div id="email">Anything I can improve? Send me an email: jacobolus AT gmail</div></body></html>