Edit: Boolean
The Edit property determines whether a label is in the edit mode.
Available values:
true. Label is in the edit mode.
false. Label is not in the edit mode (by default).
Use JSON or the setEdit method to set the property value and the getEdit method to get the property value.
The setEdit method receives following parameters:
- edit: Boolean. If argument value is set to True, then component editing is enabled, otherwise it is disabled.
- cancel: Boolean. If argument value is set to True then editing is cancelled and value before editing is returned.
To execute the example, the HTML page must contain links to the PP.js script files and the PP.css styles file in the <body> tag of the <div> item with the label identifier. Add label on the page and implement handlers of following events: Edited, Editing, ValueChanged:
// Create label label = new PP.Ui.Label({ // Set parent item ParentNode: "label", // Set contents Content: "Label", // Set width Width: 100, // Set height Height: 50, //Set attribute that label is editable ReadOnly: false, // Handle the event of the list item editing Editing: function (sender, args) { console.log("Edited label with identifier: " + sender.getId()); }, // handle the event of list item editing completion Edited: function (sender, args) { console.log("Editing of the label with identifier " + sender.getId() + " is completed"); }, // Handle the event of label contents change ValueChanged: function (sender, args) { console.log("Label contents with identifier " + sender.getId() + " is changed"); } });
Enable label editing mode:
// Enable label editing mode label.setEdit(true);
Double mouse click over the label. As a result the following message is displayed in the console:
Edit of the label with identifier: Label33
Change label contents to New. As a result the following message is displayed in the console:
Contents of the label with identifier: Label33 is changed
Editing of the label with identifier: Label33 is completed
See also: