XUL:textbox (Firefox autocomplete)
From MDC
« XUL Reference home [ Examples | Attributes | Properties | Methods | Related ]
This element is created by setting the type attribute of the textbox to autocomplete. It is used to create a textbox with a popup containing a list of possible completions for what the user has started to type.
Firefox uses a different autocomplete mechanism than the Mozilla suite. The example below will create an autocomplete textbox which will search the user's history.
- Attributes
- accesskey, autocompletepopup, autocompletesearch, autocompletesearchparam, completedefaultindex, crop, disableautocomplete, disabled, disablekeynavigation, enablehistory, focused, forcecomplete, ignoreblurwhilesearching, inputtooltiptext, label, maxlength, maxrows, minresultsforpopup, nomatch, onchange, oninput, onsearchcomplete, ontextentered, ontextreverted, open, readonly, showcommentcolumn, size, tabindex, tabscrolling, timeout, type, value
- Properties
- accessibleType, completeDefaultIndex, controller, crop, disableAutoComplete, disableKeyNavigation, disabled, editable, focused, forceComplete, ignoreBlurWhileSearching, inputField, label, maxLength, maxRows, minResultsForPopup, open, popup, popupOpen, searchCount, searchParam, selectionEnd, selectionStart, showCommentColumn, showImageColumn,size, tabIndex, tabScrolling, textLength, textValue, timeout, type, value
[edit] Examples
<textbox type="autocomplete" autocompletesearch="history"/>
[edit] Attributes
|
Inherited from XUL element |
- accesskey
- Type: character
- This should be set to a letter that is used as a shortcut key. This letter should be one of the characters that appears in the
labeltext for the element.
- autocompletepopup
- Type: id of popup element
- The id of a popup element used to hold autocomplete results for the element.
- autocompletesearch
- Type: space-separated list of values
- A space-separated list of search component names, each of which implements the nsIAutoCompleteSearch interface. The components are created using the name
@mozilla.org/autocomplete/search;1?name=where name is listed in this attribute.
-
history: Search the browser's URL history -
form-history: Search the values that the user has entered into form fields.
- autocompletesearchparam
- Type: string
- A string which is passed to the search component.
- completedefaultindex
- Type: boolean
- If
true, the best match value will be filled into the textbox as the user types. If set tofalseor omitted, the value must be selected from the list.
- crop
- Type: one of the values below
- If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the
cropattribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.
-
start: The text will be cropped on its left side. -
end: The text will be cropped on its right side. -
left: Deprecated The text will be cropped on its left side. -
right: Deprecated The text will be cropped on its right side. -
center: The text will be cropped in the middle, showing both the start and end of the text normally. -
none: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.
- disableautocomplete
- Type: boolean
- Set this attribute to
trueto disable autocomplete on the textbox. This might be used to temporarily disable autocomplete for a field.
- disabled
- Type: boolean
- Indicates whether the element is disabled or not. If this element is set to
truethe element is disabled. Disabled elements are usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused, and thecommandevent will not fire.
- disablekeynavigation
- Type: boolean
- If this attribute is not used, the user can navigate to specific items in the list by pressing the first letter of the item's label. This is done incrementally, so pressing additional keys will select more specific items. This feature may be disabled by setting this attribute to
true.
- enablehistory
- Type: boolean
- If
true, an arrow button will appear on the end of the textbox which, when pressed, will open a dropdown menu of all available results.
- focused
- Type: boolean
- This attribute is
trueif the element is focused.
- forcecomplete
- Type: boolean
- If
true, the textbox will be filled in with the best match when it loses the focus. Iffalse, it will only be filled in when the user selects an item.
- ignoreblurwhilesearching
- Type: boolean
- If
true, blur events are ignored while searching, which means that the autocomplete popup will not disappear.
- inputtooltiptext
- Type: string
- The tooltip text for the textbox.
- label
- Type: string
- The label that will appear on the element. If this is left out, no text appears.
- maxlength
- Type: integer
- The maximum number of characters that the textbox allows to be entered.
- maxrows
- Type: integer
- The number of rows to show in the results list at a time. A scrollbar will appear so the user can scroll through the remaining items.
- minresultsforpopup
- Type: integer
- The minimum number of results that must be returned for the popup to be displayed.
- nomatch
- Type: boolean
- This attribute will be set to
trueif the last search resulted in no matches.
- onchange
- Type: script code
- The code in the
onchangeattribute is called when the value of the element is changed.
- oninput
- Type: script code
- This event is sent when a user enters text in a textbox. This event is only called when the text displayed would change, thus it is not called when the user presses non-displayable keys.
- onsearchcomplete
- Type: script code
- This event handler is called when the autocomplete search is finished and results are available.
- ontextentered
- Type: script code
- This event handler is called when a result is selected for the textbox.
- ontextreverted
- Type: script code
- This event handler is called when the user presses Escape to revert the textbox to its original uncompleted value.
- open
- Type: boolean
- For the
menutype buttons, theopenattribute is set totruewhen the menu is open. Theopenattribute is not present if the menu is closed.
- readonly
- Type: boolean
- If set to
true, then the user cannot change the value of the element. However, the value may still be modified by a script.
- showcommentcolumn
- Type: boolean
- If
true, a comment column appears in the popup. For the URL history, the comment column will contain the page titles associated with each URL. If this attribute is not specified, the comment column doesn't appear.
- size
- Type: integer
- The number of characters that can be displayed in the textbox.
- tabindex
- Type: integer
- The tab order of the element. The tab order is the order in which the focus is moved when the user presses the "tab" key. Elements with a higher
tabindexare later in the tab sequence.
- tabscrolling
- Type: boolean
- If
true, the user may cycle through the results list by pressing the Tab key. Iffalse, the default, the Tab key moves the focus to the next element.
- timeout
- Type: integer
- For timed textboxes, the number of milliseconds before the timer fires a command event. The timer starts after the user types a character. If the user types another character, the timer resets.
- type
- Type: one of the values below
- You can set the type attribute to one of the values below for a more specialized type of textbox. Don't set the type if you wish to use a regular textbox.
-
autocomplete: A textbox that supports autocomplete. For more information about autocomplete textboxes, see the autocomplete documentation (Mozilla) (Firefox) -
number: A textbox that only allows the user to enter numbers. In addition, arrow buttons appear next to the textbox to let the user step through values. There are several attributes that allow the number textbox to be configured, including min, max, increment, wraparound, and hidespinbuttons. New in Firefox 3 -
password: A textbox that hides what is typed, used for entering passwords. -
timed: This textbox will fire a command event after the user types characters and a certain time has passed. The delay is set with the timeout attribute. You might use this type, for instance, to update information elsewhere in the window as the user types, without the need for continuous updates since the timer will not fire if the user types more keys in the meantime. The command event will also fire if the user presses the Enter key.
- value
- Type: string
- The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.
[edit] Properties
|
Inherited from XUL element Inherited from DOM element |
- accessibleType
- Type: integer
- A value indicating the type of accessibility object for the element.
- completeDefaultIndex
- Type: boolean
- Gets and sets the value of the completedefaultindex attribute.
- controller
- Type: nsIAutoCompleteController
- Returns the controller for the auto complete element.
- disableAutoComplete
- Type: boolean
- Gets and sets the value of the disableautocomplete attribute.
- disableKeyNavigation
- Type: boolean
- Gets or sets the value of the disableKeyNavigation attribute.
- editable
- Type: boolean
- Autocomplete fields are editable so this property always returns
true.
- forceComplete
- Type: boolean
- Gets and sets the value of the forcecomplete attribute.
- ignoreBlurWhileSearching
- Type: boolean
- Gets and sets the value of the ignoreblurwhilesearching attribute.
- inputField
- Type: textbox element
- In Mozilla, the XUL textbox is implemented as a wrapper around an HTML input element. This read only property holds a reference to this inner input element.
- maxLength
- Type: integer
- The maximum number of characters that the textbox allows to be entered.
- minResultsForPopup
- Type: integer
- Gets and sets the value of the minresultsforpopup attribute.
- popup
- Type: popup element id
- Should be set to the value of the id of the popup element that should appear when the user clicks on the textbox.
- popupOpen
- Type: boolean
- Indicates whether the popup is open or not. Set this property to open or close the popup.
- searchCount
- Type: integer
- Returns the number of search components used. This property is read only.
- searchParam
- Type: string
- Gets and sets the value of the autocompletesearchparam attribute.
- selectionEnd
- Type: integer
- Get or set the end of the selected portion of the field's text. Use in conjuction with the selectionStart property. The value specifies the index of the character after the selection. If this value is equal to the value of the selectionStart property, no text is selected, but the value indicates the position of the caret (cursor) within the textbox.
- selectionStart
- Type: integer
- Get or set the beginning of the selected portion of the field's text. Use in conjuction with the selectionEnd property. The value specifies the index of the first selected character.
- showCommentColumn
- Type: boolean
- Gets and sets the value of the showcommentcolumn attribute.
- tabScrolling
- Type: boolean
- Gets and sets the value of the tabscrolling attribute.
- textLength
- Type: integer
- Holds the length of the text entered in the textbox. This property is read-only.
- type
- Type: '
- Set to the value
autocompleteto have an autocomplete textbox.
[edit] Methods
|
Inherited from XUL element Inherited from DOM element |
- getSearchAt( index )
- Return type: string
- Returns the search component with the given index. The components are set with the autocompletesearch attribute.
- onSearchComplete()
- Return type: no return value
- Calls the onsearchcomplete event handler. You should not call this method yourself.
- onTextEntered()
- Return type: event result
- Calls the ontextentered event handler. You should not call this method yourself.
- onTextReverted()
- Return type: event result
- Calls the ontextreverted event handler. You should not call this method yourself.
- select()
- Return type: no return value
- Select all the text in the textbox.
- setSelectionRange( start, end )
- Return type: no return value
- Sets the selected portion of the textbox, where the start argument is the index of the first character to select and the end argument is the index of the character after the selection. Set both arguments to the same value to move the cursor to the corresponding position without selecting text.