macos:Editing-text
出自UXGuide.net
请帮助我们修订和更新本文的中文部分
本文的中文部分虽然取自官方最新中文版本,但与英文原版相比已落后了一年多,可能无法反映英文版本中最近的修改,且文中笔误、前后译法矛盾、未翻译完全的片断较多,请您帮助一起修订完善。详情参见中文版修订完善计划。
文字编辑
Editing Text
目录 |
In addition to the methods for selecting text, there are a number of standard ways to edit text.
除了选定文字的方法之外,编辑文字也有很多标准方式。
插入文字 Inserting Text
To insert text, the user positions the insertion point by clicking where the text is to go, then starts typing. The application moves the insertion point to the right (or left, depending on the language) as each new character is added.
在插入文字前,用户需要点击文字来设定插入点,然后开始输入。随着新的字符的输入,程序会自动的将插入点像右移(或者向左,取决于语言)。
Applications with multiple-line text blocks should support word wrap, the automatic continuation of text from the end of one line to the beginning of the next without breaking in the middle of a word.
有多行文字的程序应该支持自动换行,也就是自动的将文字从上一行继续到下一行,而不会打断英文单词。
删除文字 Deleting Text
When the user presses the Delete (or Backspace) key, one of two things happens:
当用户按下删除键(或者后退键)时,下列两件事情之一会发生:
- If text is selected, the entire selection is deleted.
- 如果有文字被选定,整个选定区域会被删除。
- If there is no current selection, the character preceding the insertion point is deleted.
- 如果没有选定文字,插入点前面的文字会被删除。
In either case, the insertion point replaces the deleted character or characters in the document. The deleted characters don’t go on to the Clipboard, but the user can undo the deletion by immediately choosing Undo from the Edit menu.
无论哪种情况,插入点都会替换被删除的字符在文档中的位置。被删除的字符不会出现在剪切板中,但是用户可以通过编辑菜单中的撤销操作立即取消删除。
You can also implement the keyboard combination Option-Delete (or Option-Backspace) to delete the word that currently contains the insertion point or to delete the part of the word to the left of the insertion point. Be sure to document this behavior if you implement it.
您可以支持通过键盘组合键Option-删除键(或者Option-后退键)来删除包含插入点的单词或者插入点左边的单词部分。如果您实现了这一行为,请确定有相应的文档说明。
If a keyboard has a Forward Delete (Fwd Del) key, the character following the insertion point is deleted each time the user presses the key.
如果键盘有前向删除键,用户每次按下这个键时,紧跟着插入点的字符会被删除。
替换选定的文字 Replacing a Selection
If the user starts typing when one or more characters are selected, the typed characters replace the selection. The deleted characters don’t go on to the Clipboard, but the user can undo the replacement by immediately choosing Undo from the Edit menu.
如果有一个或多个字符被选定时,用户开始键入字符,则被键入的字符将会替换选定的文字。选定的文字会被删除,且不会出现在剪切板中,但是用户可以通过编辑菜单中的撤销操作立即取消替换。
智能的剪切和粘贴 Intelligent Cut and Paste
Intelligent cut and paste is a set of editing features that take into account the need for spaces between words. To understand why this feature is helpful, consider the following sequence of events in a text application without intelligent cut and paste:
智能剪切和粘贴是一些考虑到单词间空格的编辑功能集合。如果想知道为什么这些功能有帮助,请考虑在一个没有智能剪切和粘贴功能的文本程序中下列事件序列:
- A sentence in the user’s document reads
用户的文档中有一句读起来如下:
Returns are only accepted if the merchandise is damaged.
The user wants to change this to
用户希望把它改成:
Returns are accepted only if the merchandise is damaged. - The user selects the word only by double-clicking. The letters are highlighted, but neither adjacent space is selected.
用户通过双击选定了only单词。所有选定的字母都会被高亮,但是没有包含空格。 - The user chooses Cut from the Edit menu, clicks just before the word if, and chooses Paste.
用户在单词if前点击,并从编辑菜单中选择粘贴。 - The sentence now reads
这个句子现在看起来像这样:
Returns are accepted onlyif the merchandise is damaged.
To correct the sentence, the user has to remove the extra space between are and accepted, and add a space between only and if.
为了改正这个句子,用户必须删除are和accepted之间多余的空格,并且在only和if之间加入空格。
If your application supports intelligent cut and paste, follow these guidelines:
如果您的程序考虑支持智能剪切和粘贴,请遵守如下准则:
- If the user selects a word or a range of words, the selection itself is highlighted, but spaces adjacent to the selection are not highlighted.
- 用户选择一个单词或者一系列单词,选定的单词本身会被高亮,但是调整的空格不会被高亮。
- When the user chooses Cut, if the character preceding the selection is a space, cut that space along with the selection. If the character preceding the selection is not a space, but the character following the selection is a space, cut that space along with the selection.
- 当用户选择剪切时,如果选择区域前的字符是空格,则会将空格和选择区域一块剪切。如果选择区域前的字符不是空格,但紧跟着选定区域的字符是空格,则该空格也将一块被剪切。
- When the user chooses Paste, if the character to the left or right of the current selection is part of a word (but not inside a word), insert a space before pasting.
- 当用户选择粘贴时,如果当前选定区域的左边或者右边是单词的一部分(但不是位于单词中键),则会先插入空格。
Use intelligent cut and paste only if the application supports the definition of a word as described in “What Constitutes a Word” These rules apply to any selection consisting of one or more whole words, no matter how the user made the selection.
只有当您的程序符合 “单词构成”小节中的单词定义时,才考虑支持智能的剪切和粘贴。这些规则适用于包含一个或者多个单词的选择区域,无论用户是怎么选定这些区域的。
Note: Intelligent cut and paste doesn’t apply to all languages. Thai, Chinese, and Japanese, for example, don’t contain spaces.
注意: 智能剪切和粘贴并不适应于所有语言。例如,泰语,中文,以及日语都不合适。
编辑文本框 Editing Text Fields
If your application isn’t primarily a text application, but it has text entry fields in dialogs, for example, you may not need to provide the full text-editing features described in this section. Ideally, an application that includes text editing should support the following features:
如果您的程序不是一个文本程序,但是在对话框中有一些文本输入框,您可能不需要提供完全的文字编辑功能。理想情况下,具有文字编辑功能的程序应该支持如下特性:
- The user can select the whole field and type in a new value, delete text, select a substring of the field and replace it, and select a word by double-clicking.
- 用户可以选择整个输入框并且输入新的字符,删除原来的文本,选择并替换子串,以及通过双击来选择单词。
- The user can choose Undo, Cut, Copy, Paste, and Delete, as described in “The Edit Menu”
- 用户可以选择撤销,剪切,复制,粘贴以及删除等功能,如 “编辑菜单”一节中所示。
- The application performs appropriate edit checks. For example, if the only legitimate value for a field is a string of digits, the application should alert the user if any nondigits are typed. For a more complete discussion of when to check for errors and apply changes in text fields, see “Accepting Changes”
- 程序会进行恰当的编辑检查。例如,如果输入框的合法字符是数字的话,则当用户输入非数字字符时,程序应该给出警告。关于文档框的错误检查和修改的更完整的讨论,请参考 “接受修改”小节。
When possible, support automatically filling in text fields as users type. If you do this, indicate what you are automatically filling in, perhaps by highlighting it, so it is clear what the user has typed and what information your application is providing.
如果可能的话,当用户在文本框输入的时候支持自动补齐。您可以使用最常用的输入信息或者从输入历史列表中选择。在自动补齐时,您的程序需要告诉用户程序在提供自动补齐,或许可以高亮自动补齐的部分,从而用户可以很清楚哪一部分是您的程序提供的。
If your application requires specific pieces of information from the user, you might assume that you should display an asterisk or custom icon next to each required text field and selection control. Doing so, however, can make your user interface appear cluttered and unappealing. To avoid this, begin by designing your user interface so that it’s easy for the user to comply with your requests. Then, if the user forgets to fill in a specific text field, you can display an asterisk or custom icon next to that field to draw attention to it. For example, if your application requires information to set up a service, make choices easy for the user by ensuring that radio buttons, pop-up menus, and other selection controls do not allow an empty selection. For text fields, wait until the user attempts to leave the current context (for example, by clicking Continue or OK), then display the “required” icon next to fields that are still empty. For some further guidelines on providing a good setup experience for your users, see “Setup Assistants”
如果您的程序需要用户某些方面的信息,您可能认为您需要在必填的输入框或者选择框旁边显示一个星号或者某些特别的图标。然而,这样会让您的用户接口看起来乱糟糟的。您应该从设计您的用户接口让用户更容易遵守您的要求开始,然后,如果用户忘记在某些输入框中填入信息的话,您可以在输入框旁显示一个星号或者定制的图标来引起用户的注意。例如,如果您的程序需要关于建立服务的信息,您可以使用单选按钮,弹出菜单或者其他的不允许空输入的选择控件。对于输入框来说,直到用户离开当前上下文(如点击继续或者确定按钮)时,才提示某些输入框是空的。关于如果提供一个好的配置体验的更多信息,请参考“配置助手”一节。
密码输入 Entering Passwords
When a user types a password into a text field, each typed character should appear as a bullet, matching the number of characters typed by the user. If the user deletes a character with the Delete key, one bullet is deleted from the text field and the insertion point moves back one bullet, as if the bullet represented an actual character. Double-clicking bulleted text in a password field selects all the bullets in the text field. To learn how to use a secure text field to implement this behavior, see About Secure Text Fields.
当用户在文本区域中输入密码时,每个输入的字符应该显示成黑点,个数和用户输入的字符个数一样。如果用户使用删除键删除了一个字符,则一个黑点也会被删除,插入点也会后移一位,就好像黑点是被输入的字符一样。双击密码框中的黑点会选择整个串。
When the user leaves the text field (by pressing Tab, for example), the number of bullets in the text field should be modified so that the field does not reflect the actual number of characters in the password.
但用户离开密码框时(例如通过Tab键),密码框黑点的数目应该被更改,从而不会泄露真正密码字符的数量。