OnClickData constructor

OnClickData({
  1. required Object menuItemId,
  2. Object? parentMenuItemId,
  3. String? mediaType,
  4. String? linkUrl,
  5. String? srcUrl,
  6. String? pageUrl,
  7. String? frameUrl,
  8. int? frameId,
  9. String? selectionText,
  10. required bool editable,
  11. bool? wasChecked,
  12. bool? checked,
})

Implementation

OnClickData({
  /// The ID of the menu item that was clicked.
  required Object menuItemId,

  /// The parent ID, if any, for the item clicked.
  Object? parentMenuItemId,

  /// One of 'image', 'video', or 'audio' if the context menu was activated on
  /// one of these types of elements.
  String? mediaType,

  /// If the element is a link, the URL it points to.
  String? linkUrl,

  /// Will be present for elements with a 'src' URL.
  String? srcUrl,

  /// The URL of the page where the menu item was clicked. This property is
  /// not set if the click occured in a context where there is no current
  /// page, such as in a launcher context menu.
  String? pageUrl,

  ///  The URL of the frame of the element where the context menu was clicked,
  /// if it was in a frame.
  String? frameUrl,

  ///  The [ID of the frame](webNavigation#frame_ids) of the element where the
  /// context menu was clicked, if it was in a frame.
  int? frameId,

  /// The text for the context selection, if any.
  String? selectionText,

  /// A flag indicating whether the element is editable (text input, textarea,
  /// etc.).
  required bool editable,

  /// A flag indicating the state of a checkbox or radio item before it was
  /// clicked.
  bool? wasChecked,

  /// A flag indicating the state of a checkbox or radio item after it is
  /// clicked.
  bool? checked,
}) : _wrapped = $js.OnClickData(
        menuItemId: switch (menuItemId) {
          int() => menuItemId.jsify()!,
          String() => menuItemId.jsify()!,
          _ => throw UnsupportedError(
              'Received type: ${menuItemId.runtimeType}. Supported types are: int, String')
        },
        parentMenuItemId: switch (parentMenuItemId) {
          int() => parentMenuItemId.jsify()!,
          String() => parentMenuItemId.jsify()!,
          null => null,
          _ => throw UnsupportedError(
              'Received type: ${parentMenuItemId.runtimeType}. Supported types are: int, String')
        },
        mediaType: mediaType,
        linkUrl: linkUrl,
        srcUrl: srcUrl,
        pageUrl: pageUrl,
        frameUrl: frameUrl,
        frameId: frameId,
        selectionText: selectionText,
        editable: editable,
        wasChecked: wasChecked,
        checked: checked,
      );