Class SearchBox

Enables the user to perform search queries and select suggestions.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(element?: HTMLElement, options?: any): SearchBox

Creates a new SearchBox.

constructor

Parameters

  • element?: HTMLElement optional

    The DOM element hosts the new SearchBox.

  • options?: any optional

    An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events.

Returns

SearchBox

Properties

public chooseSuggestionOnEnter: boolean

Gets or sets whether the first suggestion is chosen when the user presses Enter.

public disabled: boolean

Gets or sets a value that specifies whether the SearchBox is disabled. If the control is disabled, it won't receive focus.

public element: HTMLElement

Gets the DOM element that hosts the SearchBox.

public focusOnKeyboardInput: boolean

Gets or sets a value that specifies whether the search box automatically receives focus when the user types into the app window.

public placeholderText: string

Gets or sets the placeholder text for the SearchBox. This text is displayed if there is no other text in the input box.

public queryText: string

Gets or sets the query text for the SearchBox.

public searchHistoryContext: string

Gets or sets the search history context. This context is used a secondary key (the app ID is the primary key) for storing search history.

public searchHistoryDisabled: boolean

Gets or sets a value that specifies whether search history is disabled.

Methods

public addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean)

Registers an event handler for the specified event.

Parameters

  • eventName: string

    The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click".

  • eventHandler: Function

    The event handler function to associate with the event.

  • useCapture?: boolean optional

    Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase.

public dispatchEvent(type: string, eventProperties: any): boolean

Raises an event of the specified type and with additional properties.

Parameters

  • type: string

    The type (name) of the event.

  • eventProperties: any

    The set of additional properties to be attached to the event object when the event is raised.

Returns

boolean

true if preventDefault was called on the event, otherwise false.

public dispose()

Releases resources held by this SearchBox. Call this method when the SearchBox is no longer needed. After calling this method, the SearchBox becomes unusable.

public onquerychanged(eventInfo: CustomEvent)

Raised when the user or the app changes the queryText.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.queryText, detail.linguisticDetails.

public onquerysubmitted(eventInfo: CustomEvent)

Raised awhen the user clicks the search glyph or presses Enter.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.queryText, detail.linguisticDetails, detail.keyModifiers.

public onreceivingfocusonkeyboardinput(eventInfo: CustomEvent)

Raised when the app automatically redirects focus to the search box. This event can only be raised when the focusOnKeyboardInput property is set to true.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.propertyName.

public onresultsuggestionschosen(eventInfo: CustomEvent)

Raised when the user selects a suggested option for the search.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.tag, detail.keyModifiers, detail.storageFile.

public onsuggestionsrequested(eventInfo: CustomEvent)

Raised when the system requests search suggestions from this app.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.linguisticDetails, detail.queryText, detail.searchSuggestionCollection.

public removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean)

Removes an event handler that the addEventListener method registered.

Parameters

  • eventName: string

    The name of the event that the event handler is registered for.

  • eventCallback: Function

    The event handler function to remove.

  • useCapture?: boolean optional

    Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler.

public setLocalContentSuggestionSettings(settings: any)

Specifies whether suggestions based on local files are automatically displayed in the search pane, and defines the criteria that Windows uses to locate and filter these suggestions.

Parameters

  • settings: any

    The new settings for local content suggestions.