Textbox (Firefox Auto Complete)
This element is created by setting the type attribute of a 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 that the Mozilla suite. The example below will create an autocomplete textbox which will search the user's history.
Example:
<textbox type="autocomplete" autocompletesearch="history"/>
nsIAccessibleProvider nsIAutoCompleteInput nsIDOMXULMenuListElement
Attributes:
Properties and Methods:
Attributes:
Inherited from XUL Element:
align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
mousethrough
observes
ordinal
orient
pack
persist
popup
position
preference-editable
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width
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 label text for the textbox. This letter will typically be drawn underlined, although this behavior will be platform and theme specific. When the user presses ALT (or a similar key that varies on each platform) and the access key, the textbox will be activated from anywhere in the window. Although the value is case insensitive, a letter with the case matching the accesskey attribute will used if both cases exist in the label.
autocompletepopup
Type: id of popup element
The id of a popup element used to hold autocomplete results for the textbox.
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=
- 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 to false or omitted, the value must be selected from the list.
crop
Type: one of the values below
If the label of the textbox is too small to fit in its given space, the text will be cropped on the side specified by the crop attribute. 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 on both sides.
- 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 true to disable autocomplete on the textbox. This might be used to temporarily disable autocomplete for a field.
disabled
Type: boolean
Indicates whether the textbox is disabled or not. If this attribute is set to true, the textbox is disabled. This is usually drawn with the text in grey. If the textbox is disabled, it does not respond to user actions. The element cannot be focused and the command event will not fire. The element will still respond to mouse events. To enable the textbox, leave the attribute out entirely as opposed to setting the value to false.
disablekeynavigation
Type: boolean
If this attribute is not used, the user can navigate to specific items in the list by pressing the first 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 set to true if the textbox element is focused.
forcecomplete
Type: boolean
If true, the textbox will be filled in with the best match when it loses the focus. If false, 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 textbox. 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 true if the last search resulted in no matches.
onchange
Type: script code
This event is sent when the value of the textbox is changed. The event is not sent until the focus is moved to another element.
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
This event handler is called when the auto complete search is finished and results are available.
ontextentered
This event handler is called when a result is selected for the textbox.
ontextreverted
This event handler is called when the user presses Escape to revert the textbox to its original uncompleted value.
open
Type: boolean
This attribute will be set when the history popup is open. The open attribute is not present if the menu is closed.
readonly
Type: boolean
If set to true, then the user cannot modify the value of the textbox. 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. The default value of this property is false.
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 tabindex are later in the tab order sequence.
tabscrolling
Type: boolean
If true, the user may cycle through the results list by pressing the TAB key. If false, 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: string
Set to the value 'autocomplete' to have an autocomplete textbox.
value
Type: string
A value associated with the textbox. You may use it in a script for your own purposes.
Properties and Methods:
Inherited from XUL Element:
align
allowEvents
blur
boxObject
boxObject.element
boxObject.getLookAndFeelMetric
boxObject.height
boxObject.screenX
boxObject.screenY
boxObject.width
boxObject.x
boxObject.y
builder
className
click
collapsed
contextMenu
controllers
database
datasources
dir
doCommand
flex
focus
getElementsByAttribute
height
hidden
id
left
maxHeight
maxWidth
menu
minHeight
minWidth
observes
ordinal
orient
pack
persist
ref
resource
statusText
style
tooltip
tooltipText
top
width
Inherited from Element:
addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName
accessible
Type: nsIAccessible
Returns the accessibility object for the textbox.
completeDefaultIndex
Gets and sets the value of the completedefaultindex attribute.
controller
Type: nsIAutoCompleteController
Returns the controller for the auto complete element.
crop
Type: string
Gets and sets the value of the crop attribute.
disableAutoComplete
Gets and sets the value of the disableautocomplete attribute.
disableKeyNavigation
Gets and sets the value of the disablekeynavigation attribute.
disabled
Type: boolean
Gets and sets the value of the disabled attribute.
editable
Type: boolean
Autocomplete fields are editable so this property always returns true.
focused
Type: boolean
Gets and sets the value of the focused attribute.
forceComplete
Gets and sets the value of the forcecomplete attribute.
getSearchAt ( idx )
Return Type: string
Returns the search component with the given index. The components are set with the autocompletesearch attribute.
ignoreBlurWhileSearching
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.
label
Type: string
Gets and sets the value of the label attribute.
maxLength
Type: integer
The maximum number of characters that the textbox allows to be entered.
maxRows
Gets and sets the value of the maxrows attribute.
minResultsForPopup
Gets and sets the value of the minresultsforpopup attribute.
onSearchComplete ( )
Return Type: no return value
Calls the searchcomplete event handler. You should not call this method yourself.
onTextEntered ( )
Return Type: event result
Calls the textentered event handler. You should not call this method yourself.
onTextReverted ( )
Return Type: event result
Calls the textreverted event handler. You should not call this method yourself.
open
Gets and sets the value of the open 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.
select ( )
Return Type: no return value
Select all the text in the textbox.
selectionEnd
Type: integer
Get or modify the end of the selected portion of the field's text. Use in conjuction with the selectionEnd property. The value specifies the index of the character after the selection. If this value is equal to 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 modify 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.
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.
showCommentColumn
Gets and sets the value of the showcommentcolumn attribute.
size
Type: integer
The number of characters that can be displayed in the textbox.
tabIndex Mozilla 1.8
Type: integer
Get and sets the value of the tabindex attribute.
tabScrolling
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.
textValue
Type: string
Returns the content of the textbox. Equivalent to the value property.
timeout
Type: integer
Gets and sets the value of the timeout attribute.
type
Type: string
Set to the value 'autocomplete' to have an autocomplete textbox.
value
Type: string
Returns the text entered into the textbox. You can set this property to change the text in the textbox.