Dart Documentationchrome.contextMenusContextMenusCreateParams

ContextMenusCreateParams class

class ContextMenusCreateParams extends ChromeObject {
 ContextMenusCreateParams({String type, String id, String title, bool checked, List<String> contexts, var onclick, var parentId, List<String> documentUrlPatterns, List<String> targetUrlPatterns, bool enabled}) {
   if (type != null) this.type = type;
   if (id != null) this.id = id;
   if (title != null) this.title = title;
   if (checked != null) this.checked = checked;
   if (contexts != null) this.contexts = contexts;
   if (onclick != null) this.onclick = onclick;
   if (parentId != null) this.parentId = parentId;
   if (documentUrlPatterns != null) this.documentUrlPatterns = documentUrlPatterns;
   if (targetUrlPatterns != null) this.targetUrlPatterns = targetUrlPatterns;
   if (enabled != null) this.enabled = enabled;
 }
 ContextMenusCreateParams.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);

 /**
  * The type of menu item. Defaults to 'normal' if not specified.
  * enum of `normal`, `checkbox`, `radio`, `separator`
  */
 String get type => jsProxy['type'];
 set type(String value) => jsProxy['type'] = value;

 /**
  * The unique ID to assign to this item. Mandatory for event pages. Cannot be
  * the same as another ID for this extension.
  */
 String get id => jsProxy['id'];
 set id(String value) => jsProxy['id'] = value;

 /**
  * The text to be displayed in the item; this is _required_ unless _type_ is
  * 'separator'. When the context is 'selection', you can use `%s` within the
  * string to show the selected text. For example, if this parameter's value is
  * "Translate '%s' to Pig Latin" and the user selects the word "cool", the
  * context menu item for the selection is "Translate 'cool' to Pig Latin".
  */
 String get title => jsProxy['title'];
 set title(String value) => jsProxy['title'] = value;

 /**
  * The initial state of a checkbox or radio item: true for selected and false
  * for unselected. Only one radio item can be selected at a time in a given
  * group of radio items.
  */
 bool get checked => jsProxy['checked'];
 set checked(bool value) => jsProxy['checked'] = value;

 /**
  * List of contexts this menu item will appear in. Defaults to ['page'] if not
  * specified. Specifying ['all'] is equivalent to the combination of all other
  * contexts except for 'launcher'. The 'launcher' context is only supported by
  * apps and is used to add menu items to the context menu that appears when
  * clicking on the app icon in the launcher/taskbar/dock/etc. Different
  * platforms might put limitations on what is actually supported in a launcher
  * context menu.
  */
 List<String> get contexts => listify(jsProxy['contexts']);
 set contexts(List<String> value) => jsProxy['contexts'] = jsify(value);

 /**
  * A function that will be called back when the menu item is clicked. Event
  * pages cannot use this; instead, they should register a listener for
  * chrome.contextMenus.onClicked.
  */
 dynamic get onclick => jsProxy['onclick'];
 set onclick(var value) => jsProxy['onclick'] = jsify(value);

 /**
  * The ID of a parent menu item; this makes the item a child of a previously
  * added item.
  */
 dynamic get parentId => jsProxy['parentId'];
 set parentId(var value) => jsProxy['parentId'] = jsify(value);

 /**
  * Lets you restrict the item to apply only to documents whose URL matches one
  * of the given patterns. (This applies to frames as well.) For details on the
  * format of a pattern, see [Match Patterns](match_patterns.html).
  */
 List<String> get documentUrlPatterns => listify(jsProxy['documentUrlPatterns']);
 set documentUrlPatterns(List<String> value) => jsProxy['documentUrlPatterns'] = jsify(value);

 /**
  * Similar to documentUrlPatterns, but lets you filter based on the src
  * attribute of img/audio/video tags and the href of anchor tags.
  */
 List<String> get targetUrlPatterns => listify(jsProxy['targetUrlPatterns']);
 set targetUrlPatterns(List<String> value) => jsProxy['targetUrlPatterns'] = jsify(value);

 /**
  * Whether this context menu item is enabled or disabled. Defaults to true.
  */
 bool get enabled => jsProxy['enabled'];
 set enabled(bool value) => jsProxy['enabled'] = value;
}

Extends

ChromeObject > ContextMenusCreateParams

Constructors

new ContextMenusCreateParams({String type, String id, String title, bool checked, List<String> contexts, onclick, parentId, List<String> documentUrlPatterns, List<String> targetUrlPatterns, bool enabled}) #

Create a new instance of a ChromeObject, which creates and delegates to a JsObject proxy.

docs inherited from ChromeObject
ContextMenusCreateParams({String type, String id, String title, bool checked, List<String> contexts, var onclick, var parentId, List<String> documentUrlPatterns, List<String> targetUrlPatterns, bool enabled}) {
 if (type != null) this.type = type;
 if (id != null) this.id = id;
 if (title != null) this.title = title;
 if (checked != null) this.checked = checked;
 if (contexts != null) this.contexts = contexts;
 if (onclick != null) this.onclick = onclick;
 if (parentId != null) this.parentId = parentId;
 if (documentUrlPatterns != null) this.documentUrlPatterns = documentUrlPatterns;
 if (targetUrlPatterns != null) this.targetUrlPatterns = targetUrlPatterns;
 if (enabled != null) this.enabled = enabled;
}

new ContextMenusCreateParams.fromProxy(JsObject jsProxy) #

Create a new instance of a ChromeObject, which delegates to the given JsObject proxy.

docs inherited from ChromeObject
ContextMenusCreateParams.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);

Properties

bool checked #

The initial state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items.

bool get checked => jsProxy['checked'];
set checked(bool value) => jsProxy['checked'] = value;

List<String> contexts #

List of contexts this menu item will appear in. Defaults to 'page' if not specified. Specifying 'all' is equivalent to the combination of all other contexts except for 'launcher'. The 'launcher' context is only supported by apps and is used to add menu items to the context menu that appears when clicking on the app icon in the launcher/taskbar/dock/etc. Different platforms might put limitations on what is actually supported in a launcher context menu.

List<String> get contexts => listify(jsProxy['contexts']);
set contexts(List<String> value) => jsProxy['contexts'] = jsify(value);

List<String> documentUrlPatterns #

Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see Match Patterns.

List<String> get documentUrlPatterns => listify(jsProxy['documentUrlPatterns']);
set documentUrlPatterns(List<String> value) => jsProxy['documentUrlPatterns'] = jsify(value);

bool enabled #

Whether this context menu item is enabled or disabled. Defaults to true.

bool get enabled => jsProxy['enabled'];
set enabled(bool value) => jsProxy['enabled'] = value;

String id #

The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension.

String get id => jsProxy['id'];
set id(String value) => jsProxy['id'] = value;

final jsProxy #

inherited from ChromeObject
final dynamic jsProxy

var onclick #

A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for chrome.contextMenus.onClicked.

dynamic get onclick => jsProxy['onclick'];
set onclick(var value) => jsProxy['onclick'] = jsify(value);

var parentId #

The ID of a parent menu item; this makes the item a child of a previously added item.

dynamic get parentId => jsProxy['parentId'];
set parentId(var value) => jsProxy['parentId'] = jsify(value);

List<String> targetUrlPatterns #

Similar to documentUrlPatterns, but lets you filter based on the src attribute of img/audio/video tags and the href of anchor tags.

List<String> get targetUrlPatterns => listify(jsProxy['targetUrlPatterns']);
set targetUrlPatterns(List<String> value) => jsProxy['targetUrlPatterns'] = jsify(value);

String title #

The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin".

String get title => jsProxy['title'];
set title(String value) => jsProxy['title'] = value;

String type #

The type of menu item. Defaults to 'normal' if not specified. enum of normal, checkbox, radio, separator

String get type => jsProxy['type'];
set type(String value) => jsProxy['type'] = value;

Methods

JsObject toJs() #

inherited from ChromeObject
JsObject toJs() => jsProxy;

String toString() #

inherited from ChromeObject

Returns a string representation of this object.

docs inherited from Object
String toString() => jsProxy.toString();