EventArgs(event: Function);
event. Event object.
The EventArgs method creates an instance of the EventArgs class.
To execute the example, the HTML page must contain links to the PP.js scenario file and the PP.css styles file. Add A and B buttons to the page, process button click events by showing button names to browser console:
// Create the A button var buttonA = new PP.Ui.Button({ Height: 100, Width: 100, Content: "A" }); //Create the B button var buttonB = new PP.Ui.Button({ Height: 100, Width: 100, Content: "B" }); // Process the Click event buttonA.Click.add(function (sender, args) { // Create an object of the EventArgs type var newArgs = new PP.EventArgs(); // Add the Content field and write button name to it newArgs.Content = "A"; // Fire a B button click event buttonB.Click.fire(sender, newArgs); }); // Add a B button click event handler buttonB.Click.add(function (sender, args) { if (args.Content != "" & args.Content != undefined) { console.log("Clicked button name: " + args.Content) } else { console.log("Clicked button name: " + args.Event.target.textContent) } }); // Add both buttons to the document buttonA.addToNode(document.body); buttonB.addToNode(document.body);
After executing the example two buttons are added in the page, Clicking these buttons shows their names to the browser console:
Name of the clicked button: A
Name of the clicked button: B
See also: