Class SearchEntry

All Implemented Interfaces:
PointerInterface

public class SearchEntry extends Widget
`GtkSearchEntry` is an entry widget that has been tailored for use
as a search entry.

The main API for interacting with a `GtkSearchEntry` as entry
is the `GtkEditable` interface.

![An example GtkSearchEntry](search-entry.png)

It will show an inactive symbolic “find” icon when the search
entry is empty, and a symbolic “clear” icon when there is text.
Clicking on the “clear” icon will empty the search entry.

To make filtering appear more reactive, it is a good idea to
not react to every change in the entry text immediately, but
only after a short delay. To support this, `GtkSearchEntry`
emits the [signal@Gtk.SearchEntry::search-changed] signal which
can be used instead of the [signal@Gtk.Editable::changed] signal.

The [signal@Gtk.SearchEntry::previous-match],
[signal@Gtk.SearchEntry::next-match] and
[signal@Gtk.SearchEntry::stop-search] signals can be used to
implement moving between search results and ending the search.

Often, `GtkSearchEntry` will be fed events by means of being
placed inside a [class@Gtk.SearchBar]. If that is not the case,
you can use [method@Gtk.SearchEntry.set_key_capture_widget] to
let it capture key input from another widget.

`GtkSearchEntry` provides only minimal API and should be used with
the [iface@Gtk.Editable] API.

## CSS Nodes

```
entry.search
╰── text
```

`GtkSearchEntry` has a single CSS node with name entry that carries
a `.search` style class, and the text node is a child of that.

## Accessibility

`GtkSearchEntry` uses the %GTK_ACCESSIBLE_ROLE_SEARCH_BOX role.

https://docs.gtk.org/gtk4/class.SearchEntry.html

  • Field Details

  • Constructor Details

    • SearchEntry

      public SearchEntry(PointerContainer pointer)
    • SearchEntry

      public SearchEntry()
      Creates a `GtkSearchEntry`.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getKeyCaptureWidget

      public Widget getKeyCaptureWidget()
      Gets the widget that @entry is capturing key events from.
      Returns:
      The key capture widget.
    • getSearchDelay

      public int getSearchDelay()
      Get the delay to be used between the last keypress and the
      [signal@Gtk.SearchEntry::search-changed] signal being emitted.
      Returns:
      a delay in milliseconds.
    • setKeyCaptureWidget

      public void setKeyCaptureWidget(@Nullable Widget widget)
      Sets @widget as the widget that @entry will capture key
      events from.

      Key events are consumed by the search entry to start or
      continue a search.

      If the entry is part of a `GtkSearchBar`, it is preferable
      to call [method@Gtk.SearchBar.set_key_capture_widget] instead,
      which will reveal the entry in addition to triggering the
      search entry.

      Note that despite the name of this function, the events
      are only 'captured' in the bubble phase, which means that
      editable child widgets of @widget will receive text input
      before it gets captured. If that is not desired, you can
      capture and forward the events yourself with
      [method@Gtk.EventControllerKey.forward].
      Parameters:
      widget - a `GtkWidget`
    • setSearchDelay

      public void setSearchDelay(int delay)
      Set the delay to be used between the last keypress and the
      [signal@Gtk.SearchEntry::search-changed] signal being emitted.
      Parameters:
      delay - a delay in milliseconds
    • onActivate

      public SignalHandler onActivate(SearchEntry.OnActivate signal)
      Connect to signal "activate".
      See SearchEntry.OnActivate.onActivate() for signal description.
      Field SIGNAL_ON_ACTIVATE contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onNextMatch

      public SignalHandler onNextMatch(SearchEntry.OnNextMatch signal)
      Connect to signal "next-match".
      See SearchEntry.OnNextMatch.onNextMatch() for signal description.
      Field SIGNAL_ON_NEXT_MATCH contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onPreviousMatch

      public SignalHandler onPreviousMatch(SearchEntry.OnPreviousMatch signal)
      Connect to signal "previous-match".
      See SearchEntry.OnPreviousMatch.onPreviousMatch() for signal description.
      Field SIGNAL_ON_PREVIOUS_MATCH contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onSearchChanged

      public SignalHandler onSearchChanged(SearchEntry.OnSearchChanged signal)
      Connect to signal "search-changed".
      See SearchEntry.OnSearchChanged.onSearchChanged() for signal description.
      Field SIGNAL_ON_SEARCH_CHANGED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onSearchStarted

      public SignalHandler onSearchStarted(SearchEntry.OnSearchStarted signal)
      Connect to signal "search-started".
      See SearchEntry.OnSearchStarted.onSearchStarted() for signal description.
      Field SIGNAL_ON_SEARCH_STARTED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onStopSearch

      public SignalHandler onStopSearch(SearchEntry.OnStopSearch signal)
      Connect to signal "stop-search".
      See SearchEntry.OnStopSearch.onStopSearch() for signal description.
      Field SIGNAL_ON_STOP_SEARCH contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • asEditable

      public Editable asEditable()
      Implements interface Editable. Call this to get access to interface functions.
      Returns:
      Editable
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()