Class FindController

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public final class FindController extends GObject

Controls text search in a WebKitWebView.

A WebKitFindController is used to search text in a WebKitWebView. You can get a WebKitWebView's WebKitFindController with webkit_web_view_get_find_controller(), and later use it to search for text using webkit_find_controller_search(), or get the number of matches using webkit_find_controller_count_matches(). The operations are asynchronous and trigger signals when ready, such as WebKitFindController::found-text, WebKitFindController::failed-to-find-text or WebKitFindController::counted-matches.

  • Constructor Details

    • FindController

      public FindController(MemorySegment address)
      Create a FindController instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • FindController

      public FindController()
      Create a new FindController.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the FindController class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected FindController asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • countMatches

      public void countMatches(String searchText, int findOptions, int maxMatchCount)

      Counts the number of matches for searchText.

      Counts the number of matches for searchText found in the WebKitWebView with the provided findOptions. The number of matches will be provided by the WebKitFindController::counted-matches signal.

      Parameters:
      searchText - the text to look for
      findOptions - a bitmask with the WebKitFindOptions used in the search
      maxMatchCount - the maximum number of matches allowed in the search
    • getMaxMatchCount

      public int getMaxMatchCount()

      Gets the maximum number of matches to report.

      Gets the maximum number of matches to report during a text lookup. This number is passed as the last argument of webkit_find_controller_search() or webkit_find_controller_count_matches().

      Returns:
      the maximum number of matches to report.
    • getOptions

      public int getOptions()

      Gets the WebKitFindOptions for the current search.

      Gets a bitmask containing the WebKitFindOptions associated with the current search.

      Returns:
      a bitmask containing the WebKitFindOptions associated with the current search.
    • getSearchText

      public String getSearchText()

      Gets the text that this FindController is searching for.

      Gets the text that this FindController is currently searching for. This text is passed to either webkit_find_controller_search() or webkit_find_controller_count_matches().

      Returns:
      the text to look for in the WebKitWebView.
    • getWebView

      public WebView getWebView()

      Gets the WebKitWebView this find controller is associated to.

      Do not dereference the returned instance as it belongs to the WebKitFindController.

      Returns:
      the WebKitWebView.
    • search

      public void search(String searchText, int findOptions, int maxMatchCount)

      Looks for searchText associated with findController.

      Looks for searchText in the WebKitWebView associated with this FindController since the beginning of the document highlighting up to maxMatchCount matches. The outcome of the search will be asynchronously provided by the WebKitFindController::found-text and WebKitFindController::failed-to-find-text signals.

      To look for the next or previous occurrences of the same text with the same find options use webkit_find_controller_search_next() and/or webkit_find_controller_search_previous(). The WebKitFindController will use the same text and options for the following searches unless they are modified by another call to this method.

      Note that if the number of matches is higher than maxMatchCount then WebKitFindController::found-text will report G_MAXUINT matches instead of the actual number.

      Callers should call webkit_find_controller_search_finish() to finish the current search operation.

      Parameters:
      searchText - the text to look for
      findOptions - a bitmask with the WebKitFindOptions used in the search
      maxMatchCount - the maximum number of matches allowed in the search
    • searchFinish

      public void searchFinish()

      Finishes a find operation.

      Finishes a find operation started by webkit_find_controller_search(). It will basically unhighlight every text match found.

      This method will be typically called when the search UI is closed/hidden by the client application.

    • searchNext

      public void searchNext()

      Looks for the next occurrence of the search text.

      Calling this method before webkit_find_controller_search() or webkit_find_controller_count_matches() is a programming error.

    • searchPrevious

      public void searchPrevious()

      Looks for the previous occurrence of the search text.

      Calling this method before webkit_find_controller_search() or webkit_find_controller_count_matches() is a programming error.

    • onCountedMatches

      This signal is emitted when the WebKitFindController has counted the number of matches for a given text after a call to webkit_find_controller_count_matches().
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitCountedMatches

      public void emitCountedMatches(int matchCount)
      Emits the "counted-matches" signal. See onCountedMatches(FindController.CountedMatchesCallback).
    • onFailedToFindText

      This signal is emitted when a search operation does not find any result for the given text. It will be issued if the text is not found asynchronously after a call to webkit_find_controller_search(), webkit_find_controller_search_next() or webkit_find_controller_search_previous().
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitFailedToFindText

      public void emitFailedToFindText()
      Emits the "failed-to-find-text" signal. See onFailedToFindText(FindController.FailedToFindTextCallback).
    • onFoundText

      This signal is emitted when a given text is found in the web page text. It will be issued if the text is found asynchronously after a call to webkit_find_controller_search(), webkit_find_controller_search_next() or webkit_find_controller_search_previous().
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitFoundText

      public void emitFoundText(int matchCount)
      Emits the "found-text" signal. See onFoundText(FindController.FoundTextCallback).
    • builder

      public static FindController.Builder<? extends FindController.Builder> builder()
      A FindController.Builder object constructs a FindController with the specified properties. Use the various set...() methods to set properties, and finish construction with FindController.Builder.build().
      Returns:
      the builder object