Interface WebView.ScriptDialogCallback

All Superinterfaces:
FunctionPointer
Enclosing class:
WebView
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface WebView.ScriptDialogCallback extends FunctionPointer

Functional interface declaration of the ScriptDialogCallback callback.

See Also:
  • Method Details

    • run

      boolean run(@Nullable ScriptDialog dialog)

      Emitted when JavaScript code calls window.alert, window.confirm or window.prompt, or when onbeforeunload event is fired. The dialog parameter should be used to build the dialog. If the signal is not handled a different dialog will be built and shown depending on the dialog type: ScriptDialogType.ALERT: message dialog with a single Close button. ScriptDialogType.CONFIRM: message dialog with OK and Cancel buttons. ScriptDialogType.PROMPT: message dialog with OK and Cancel buttons and a text entry with the default text. ScriptDialogType.BEFORE_UNLOAD_CONFIRM: message dialog with Stay and Leave buttons.

      It is possible to handle the script dialog request asynchronously, by simply caling webkit_script_dialog_ref() on the dialog argument and calling webkit_script_dialog_close() when done. If the last reference is removed on a WebKitScriptDialog and the dialog has not been closed, webkit_script_dialog_close() will be called.

    • upcall

      default int upcall(MemorySegment sourceWebView, MemorySegment dialog)
      The upcall method is called from native code. The parameters are marshaled and run(ScriptDialog) is executed.
    • toCallback

      default MemorySegment toCallback(Arena arena)
      Creates a native function pointer to the upcall(MemorySegment, MemorySegment) method.
      Specified by:
      toCallback in interface FunctionPointer
      Parameters:
      arena - the arena in which the function pointer is allocated
      Returns:
      the native function pointer