M. E. brauchst du dort nichts ersetzen. onCommand und onCreated sind keine Inline-Eventhandler. Achte hier auf die Schreibweise: Inline-Eventhandler werden durchweg klein geschrieben, da gibt es keine Großbuchstaben.
Noch als Ergänzung: Die Funktion CreateWidget(aProperties) erwartet ein Objekt mit bestimmten Eigenschaftswerten bzw. Elementen. OnCommand und OnCreated sind genauso Elemente dieses Übergabeobjekts wie zB:. id und type, aber eben als 'Funktionsparamter'. Das hat, wie du richtig gesagt hast, nichts mit inline-Eventhandlern zu tun und da darf natürlich auch nichts angepasst werden.
In JavaScript hat ein Objekt ja formal folgendes Aussehen:
const meinObjekt = {
Eigenschaftsname_1: Wert_1,
Eigenschaftsname_2: Wert_2,
...
Eigenschaftsname_n: Wert_n,
};
Wie üblich bei den hier verwendeten UserSkripten wird dann dieses Übergabeobjekt mit dem gesamten Startcode gleich in den Funktionsaufruf hineingeschrieben, was von der Syntax dann so aussieht wie bekannt (und was ich persönlich nicht sehr übersichtlich finde).
Hier sind alle möglichen Eigenschaften für das CreateWidget-Objekt aufgelistet:
/**
* Create a widget.
*
* To create a widget, you should pass an object with its desired
* properties. The following properties are supported:
*
* - id: the ID of the widget (required).
* - type: a string indicating the type of widget. Possible types
* are:
* 'button' - for simple button widgets (the default)
* 'view' - for buttons that open a panel or subview,
* depending on where they are placed.
* 'button-and-view' - A combination of 'button' and 'view',
* which looks different depending on whether it's
* located in the toolbar or in the panel: When
* located in the toolbar, the widget is shown as
* a combined item of a button and a dropmarker
* button. The button triggers the command and the
* dropmarker button opens the view. When located
* in the panel, shown as one item which opens the
* view, and the button command cannot be
* triggered separately.
* 'custom' - for fine-grained control over the creation
* of the widget.
* - viewId: Only useful for views and button-and-view widgets (and
* required there): the id of the <panelview> that should be
* shown when clicking the widget. If used with a custom
* widget, the widget must also provide a toolbaritem where
* the first child is the view button.
* - onBuild(aDoc): Only useful for custom widgets (and required there); a
* function that will be invoked with the document in which
* to build a widget. Should return the DOM node that has
* been constructed.
* - onBeforeCreated(aDoc): Attached to all non-custom widgets; a function
* that will be invoked before the widget gets a DOM node
* constructed, passing the document in which that will happen.
* This is useful especially for 'view' type widgets that need
* to construct their views on the fly (e.g. from bootstrapped
* add-ons). If the function returns `false`, the widget will
* not be created.
* - onCreated(aNode): Attached to all widgets; a function that will be invoked
* whenever the widget has a DOM node constructed, passing the
* constructed node as an argument.
* - onDestroyed(aDoc): Attached to all non-custom widgets; a function that
* will be invoked after the widget has a DOM node destroyed,
* passing the document from which it was removed. This is
* useful especially for 'view' type widgets that need to
* cleanup after views that were constructed on the fly.
* - onBeforeCommand(aEvt, aNode): A function that will be invoked when the user
* activates the button but before the command
* is evaluated. Useful if code needs to run to
* change the button's icon in preparation to the
* pending command action. Called for any type that
* supports the handler. The command type, either
* "view" or "command", may be returned to force the
* action that will occur. View will open the panel
* and command will result in calling onCommand.
* - onCommand(aEvt): Useful for custom, button and button-and-view widgets; a
* function that will be invoked when the user activates
* the button. A custom widget with a view should
* return "view" or "command" to continue processing
* the command per the needs of the widget.
* - onClick(aEvt): Attached to all widgets; a function that will be invoked
* when the user clicks the widget.
* - onViewShowing(aEvt): Only useful for views and button-and-view widgets; a
* function that will be invoked when a user shows your view.
* If any event handler calls aEvt.preventDefault(), the view
* will not be shown.
*
* The event's `detail` property is an object with an
* `addBlocker` method. Handlers which need to
* perform asynchronous operations before the view is
* shown may pass this method a Promise, which will
* prevent the view from showing until it resolves.
* Additionally, if the promise resolves to the exact
* value `false`, the view will not be shown.
* - onViewHiding(aEvt): Only useful for views; a function that will be
* invoked when a user hides your view.
* - l10nId: fluent string identifier to use for localizing attributes
* on the widget. If present, preferred over the
* label/tooltiptext.
* - tooltiptext: string to use for the tooltip of the widget
* - label: string to use for the label of the widget
* - localized: If true, or undefined, attempt to retrieve the
* widget's string properties from the customizable
* widgets string bundle.
* - removable: whether the widget is removable (optional, default: true)
* NB: if you specify false here, you must provide a
* defaultArea, too.
* - overflows: whether widget can overflow when in an overflowable
* toolbar (optional, default: true)
* - defaultArea: default area to add the widget to
* (optional, default: none; required if non-removable)
* - shortcutId: id of an element that has a shortcut for this widget
* (optional, default: null). This is only used to display
* the shortcut as part of the tooltip for builtin widgets
* (which have strings inside
* customizableWidgets.properties). If you're in an add-on,
* you should not set this property.
* If l10nId is provided, the resulting shortcut is passed
* as the "$shortcut" variable to the fluent message.
* - showInPrivateBrowsing: whether to show the widget in private browsing
* mode (optional, default: true)
* - hideInNonPrivateBrowsing: whether to hide the widget in non private
* browsing mode windows (optional, default: false)
* - tabSpecific: If true, closes the panel if the tab changes.
* - locationSpecific: If true, closes the panel if the location changes.
* This is similar to tabSpecific, but also if the location
* changes in the same tab, we may want to close the panel.
* - webExtension: Set to true if this widget is being created on behalf of an
* extension.
*
* @param aProperties the specifications for the widget.
* @return a wrapper around the created widget (see getWidget)
*/
Alles anzeigen