ui.ac.RichInputHandler Extends goog.ui.ac.InputHandler
Class for managing the interaction between an autocomplete object and a text-input or textarea.

Inheritance

Constructor

goog.ui.ac.RichInputHandler(opt_separatorsopt_literalsopt_multiopt_throttleTime)

Parameters

opt_separators : ?string=
Seperators to split multiple entries.
opt_literals : ?string=
Characters used to delimit text literals.
opt_multi : ?boolean=
Whether to allow multiple entries (Default: true).
opt_throttleTime : ?number=
Number of milliseconds to throttle keyevents with (Default: 150).

Instance Methods

Public Protected Private
selectRow(row) boolean
Selects the given rich row. The row's select(target) method is called.
Arguments:
row : Object
The row to select.
Returns: boolean  Whether to suppress the update event.
code »
addEventHandlers_()
Adds the necessary input event handlers.
code »
attachAutoComplete(ac)
Attach an instance of an AutoComplete
Arguments:
ac : goog.ui.ac.AutoComplete
Autocomplete object.
code »
attachInput(target)
Attaches the input handler to a target element. The target element should be a textarea, input box, or other focusable element with the same interface.
Arguments:
target : Element | goog.events.EventTarget
An element to attach the input handler too.
code »
attachInputs(var_args)
Attaches the input handler to multiple elements.
Arguments:
var_args : ...Element
Elements to attach the input handler too.
code »
detachInput(target)
Detaches the input handler from the provided element.
Arguments:
target : Element | goog.events.EventTarget
An element to detach the input handler from.
code »
detachInputs(var_args)
Detaches the input handler from multuple elements.
Arguments:
var_args : ...Element
Variable arguments for elements to unbind from.
code »
disposeInternal()
No description.
code »
getActiveElement() Element
Returns the current active element.
Returns: Element  The currently active element.
code »
getAutoComplete() goog.ui.ac.AutoComplete
Returns the associated autocomplete instance.
Returns: goog.ui.ac.AutoComplete  The associated autocomplete instance.
code »
getCursorPosition() number
Returns the current cursor position.
Returns: number  The index of the cursor position.
code »
getThrottleTime() number
Gets the time to wait before updating the results. If the update during typing flag is switched on, this delay counts from the last update, otherwise from the last keypress.
Returns: number  Throttle time in milliseconds.
code »
getTokenIndex_(textcaret) number
Gets the index of the currently highlighted token
Arguments:
text : string
string to parse.
caret : number
Position of cursor in string.
Returns: number  Index of token.
code »
getUpdateDuringTyping() boolean
Gets whether the result list is updated during typing.
Returns: boolean  Value of the flag.
code »
getValue() string
Returns the value of the current active element.
Returns: string  The value of the current active element.
code »
handleBlur(opt_e)
Handles an element blurring.
Arguments:
opt_e : goog.events.Event=
Browser event object.
code »
handleFocus(e)
Handles an element getting focus.
Arguments:
e : goog.events.Event
Browser event object.
code »
handleKeyEvent(e) boolean
Handles a key event.
Arguments:
e : goog.events.BrowserEvent
Browser event object.
Returns: boolean  True if the key event was handled.
code »
handleKeyUp(e) boolean
Handles the key up event. Registered only if needKeyUpListener returns true.
Arguments:
e : goog.events.Event
The keyup event.
Returns: boolean  Whether an action was taken or not.
code »
handleMouseDown(e)
For subclasses to override to handle the mouse-down event.
Arguments:
e : goog.events.BrowserEvent
Browser event object.
code »
handleSeparator_(e) boolean
Handles a key event for a separator key.
Arguments:
e : goog.events.BrowserEvent
Browser event object.
Returns: boolean  True if the key event was handled.
code »
moveDown_() boolean
Moves hilite down. May hilite next or previous depending on orientation.
Returns: boolean  True if successful.
code »
moveUp_() boolean
Moves hilite up. May hilite next or previous depending on orientation.
Returns: boolean  True if successful.
code »
needKeyUpListener() boolean
No description.
Returns: boolean  Whether this inputhandler need to listen on key-up.
code »
onIeKeyPress_(e)
Handles the key-press event for IE, checking to see if the user typed a separator character.
Arguments:
e : goog.events.BrowserEvent
Browser event object.
code »
onKeyDownOnInactiveElement_(e)
Handles typing in an inactive input element. Activate it.
Arguments:
e : goog.events.BrowserEvent
Browser event object.
code »
onKeyPress_(e)
Handles a KEYPRESS event generated by typing in the active input element. Checks if IME input is ended.
Arguments:
e : goog.events.BrowserEvent
Browser event object.
code »
onKeyUp_(e)
Handles the key-up event. This is only ever used by Mac FF or when we are in an IME entry scenario.
Arguments:
e : goog.events.BrowserEvent
Browser event object.
code »
onKey_(e)
Handles typing in the active input element. Checks if the key is a special key and does the relevent action as appropriate.
Arguments:
e : goog.events.BrowserEvent
Browser event object.
code »
onMouseDown_(e)
Handles mouse-down event.
Arguments:
e : goog.events.BrowserEvent
Browser event object.
code »
onTick_(e)
Handles the timer's tick event. Calculates the current token, and reports any update to the autocomplete.
Arguments:
e : goog.events.Event
Browser event object.
code »
parseToken() string
Parses a text area or input box for the currently highlighted token.
Returns: string  Token to complete.
code »
parseToken_() string
Parses a text area or input box for the currently highlighted token.
Returns: string  Token to complete.
code »
processBlur()
Helper function that does the logic to handle an element blurring.
code »
processFocus(target)
Registers handlers for the active element when it receives focus.
Arguments:
target : Element
The element to focus.
code »
removeEventHandlers_()
Removes the necessary input event handlers.
code »
selectRow(rowopt_multi) boolean
Selects the given row. Implements the SelectionHandler interface.
Arguments:
row : Object
The row to select.
opt_multi : boolean=
Should this be treated as a single or multi-token auto-complete? Overrides previous setting of opt_multi on constructor.
Returns: boolean  Whether to suppress the update event.
code »
setCursorPosition(pos)
Sets the cursor at the given position.
Arguments:
pos : number
The index of the cursor position.
code »
setGenerateNewTokenOnLiteral(newValue)
Sets whether new tokens should be generated from literals. That is, should hello'world be two tokens, assuming ' is a literal?
Arguments:
newValue : boolean
boolean value indicating whether or not new tokens should be generated from literals.
code »
setPreventDefaultOnTab(newValue)
Sets whether we will prevent the default input behavior (moving focus to the next focusable element) on TAB.
Arguments:
newValue : boolean
Whether to preventDefault on TAB.
code »
setRowJustSelected(justSelected)
Sets whether a row has just been selected.
Arguments:
justSelected : boolean
Whether or not the row has just been selected.
code »
setSeparatorCompletes(newValue)
Sets whether separators perform autocomplete.
Arguments:
newValue : boolean
Whether to autocomplete on separators.
code »
setSeparatorSelects(newValue)
Sets whether separators perform autocomplete.
Arguments:
newValue : boolean
Whether to autocomplete on separators.
code »
setSeparators(separatorsopt_defaultSeparators)
Sets the entry separator characters.
Arguments:
separators : string
The separator characters to set.
opt_defaultSeparators : string=
The defaultSeparator character to set.
code »
setThrottleTime(time)
Sets the time to wait before updating the results.
Arguments:
time : number
New throttle time in milliseconds.
code »
setTokenText(tokenTextopt_multi)
Sets the text of the current token without updating the autocomplete choices.
Arguments:
tokenText : string
The text for the current token.
opt_multi : boolean=
Should this be treated as a single or multi-token auto-complete? Overrides previous setting of opt_multi on constructor.
code »
setTrimmingRegExp(trimmer)
Sets the regular expression used to trim the tokens before passing them to the matcher: every substring that matches the given regular expression will be removed. This can also be set to null to disable trimming.
Arguments:
trimmer : RegExp
Regexp to use for trimming or null to disable it.
code »
setUpdateDuringTyping(value)
Sets whether the result list should be updated during typing.
Arguments:
value : boolean
New value of the flag.
code »
setUpsideDown(upsideDown)
Sets whether to flip the orientation of up & down for hiliting next and previous autocomplete entries.
Arguments:
upsideDown : boolean
Whether the orientation is upside down.
code »
setValue(value)
Sets the value of the current active element.
Arguments:
value : string
The new value.
code »
setWhitespaceWrapEntries(newValue)
Sets whether auto-completed tokens should be wrapped with whitespace.
Arguments:
newValue : boolean
boolean value indicating whether or not auto-completed tokens should be wrapped with whitespace.
code »
splitInput_(text) !Array
Splits an input string of text at the occurance of a character in goog.ui.ac.InputHandler.prototype.separators_ and creates an array of tokens. Each token may contain additional whitespace and formatting marks. If necessary use goog.ui.ac.InputHandler.prototype.trim_ to clean up the entries.
Arguments:
text : string
Input text.
Returns: !Array  Parsed array.
code »
startWaitingForIme_()
Starts waiting for IME.
code »
stopWaitingForIme_()
Stops waiting for IME.
code »
trim_(text) string
Trims a token of characters that we want to ignore
Arguments:
text : string
string to trim.
Returns: string  Trimmed string.
code »
update(opt_force)
Checks if an update has occurred and notified the autocomplete of the new token.
Arguments:
opt_force : boolean=
If true the menu will be forced to update.
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
  mypackage.MyClass = function() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

constructor :
No description.
Code »
The AutoComplete instance this inputhandler is associated with.
Code »
activateHandler_ : goog.events.EventHandler
Event handler to help us find an input element that already has the focus.
Code »
activeElement_ :
The element that is currently active.
Code »
activeTimeoutId_ :
The id of the currently active timeout, so it can be cleared if required.
Code »
constructor :
No description.
Code »
defaultSeparator_ :
The separator we use to reconstruct the string
Code »
Event handler used by the input handler to manage events.
Code »
generateNewTokenOnLiteral_ :
Should the occurrence of a literal indicate a token boundary?
Code »
keyHandler_ : goog.events.KeyHandler
The keyhandler used for listening on most key events. This takes care of abstracting away some of the browser differences.
Code »
lastKeyCode_ :
The last key down key code.
Code »
lastValue_ :
The previous value of the active element.
Code »
literals_ :
Characters that are used to delimit literal text. Separarator characters found within literal text are not processed as separators
Code »
multi_ :
Whether this input accepts multiple values
Code »
preventDefaultOnTab_ :
Whether to prevent the default behavior (moving focus to another element) when tab is pressed. This occurs by default only for multi-value mode.
Code »
rowJustSelected_ :
Flag used to indicate that the user just selected a row and we should therefore ignore the change of the input value.
Code »
separatorCheck_ :
Regular expression to test whether a separator exists
Code »
separatorSelects_ :
If we're in 'multi' mode, does typing a separator force the current term to autocomplete? For example, if 'tomato' is a suggested completion and the user has typed 'to,', do we autocomplete to turn that into 'tomato,'?
Code »
separatorUpdates_ :
If we're in 'multi' mode, does typing a separator force the updating of suggestions? For example, if somebody finishes typing "obama, hillary,", should the last comma trigger updating suggestions in a guaranteed manner? Especially useful when the suggestions depend on complete keywords. Note that "obama, hill" (a leading sub-string of "obama, hillary" will lead to different and possibly irrelevant suggestions.
Code »
separators_ :
Characters that can be used to split multiple entries in an input string
Code »
timer_ : goog.Timer
A timer object used to monitor for changes when an element is active. TODO(user): Consider tuning the throttle time, so that it takes into account the length of the token. When the token is short it is likely to match lots of rows, therefore we want to check less frequently. Even something as simple as <3-chars = 150ms, then 100ms otherwise.
Code »
trimmer_ :
Regular expression used from trimming tokens or null for no trimming.
Code »
updateDuringTyping_ :
Flag indicating whether the result list should be updated continuously during typing or only after a short pause.
Code »
upsideDown_ :
Whether to flip the orientation of up & down for hiliting next and previous autocomplete entries.
Code »
waitingForIme_ :
Flag used to indicate that the IME key has been seen and we need to wait for the up event.
Code »
whitespaceWrapEntries_ :
Should auto-completed tokens be wrapped in whitespace? Used in selectRow.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Properties

goog.ui.ac.RichInputHandler.superClass_ :
No description.
Code »

Package ui.ac

Package Reference