javascript - why is my custom control event not registered? -
i'm using custom control in app, properties , behavior. when want fire event, doesn't work! instead says: "firepress not function".
here sample code of control:
sap.ui.core.control.extend("mycontrols.customcontent", { metadata: { properties: { enabled: {type: "boolean", defaultvalue: true}, title: {type: "string", defaultvalue: null}, icon: {type: "sap.ui.core.uri", defaultvalue: null}, size: {type: "sap.ui.core.csssize", defaultvalue: "200px"} } }, // control events events: { press: {enablepreventdefault : true} }, // browser events: ontap: function (oevent) { this.firepress({}); // -> not working! } }); i've read when declare event, ui5 framework automatically generate methods registering (attachyourevent), de-registering (detachyourevent) , firing events (fireyourevent): see sapui5 custom pseudo-event
what missing ?
actually, it's because "events" must member of "metadata"! correct code be:
sap.ui.core.control.extend("mycontrols.customcontent", { metadata: { properties: { // etc... }, events: { press: {} } }, // browser events: ontap: function (oevent) { this.firepress({}); // -> work now! } });
Comments
Post a Comment