cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with Custom Control in SAPUI5

former_member243729
Participant
0 Kudos

Hi, I am extending a standard button control by adding an event, which is not working. I get error 'Control did not return a class definition from sap.ui.define. - XMLTemplateProcessor'.

Below is the code.

sap.ui.define([],
	function(){
		sap.m.Button.extend("com.xyz.ui5.abc.util.customDate",{
		metaData:{
			properties: {},
			aggregations: {},
			events: {
			          donald: {}
				}
                      },
			"onmousehover": function(){
				this.fireDonald();
			},
		renderer: function(oRm, oControl){
                }
	});
    }
);

and below is what I added in my fragment. But I do not even see the button, forget about the event triggering. May I know what could be wrong with this

<xmlns:paul = "com.xyz.ui5.abc.util">

<paul:customDate text = "Custom Button" donald = "showMessageOnHover"></paul:customDate>

Accepted Solutions (1)

Accepted Solutions (1)

WouterLemaire
Active Contributor

"metaData" should be lowercase "metadata"

You can also put "sap.m.Button" in the define, functionality will be the same...

Here you have an example of what you want to do: https://ui5.sap.com/#/topic/d5b756bf4e9a4d67961fa21e1ba12c9e

Answers (1)

Answers (1)

former_member182862
Active Contributor

it can be something like

sap.ui.define(["sap/m/Button"], function (Button) {
  Button.extend("customButton",{
    metadata:{
      events: {
        mouseover: {}
      }
    },
    renderer: {},
    onAfterRendering: function() {
      if (Button.prototype.onAfterRendering) {
        Button.prototype.onAfterRendering.apply(this, arguments);
      }
      this.$().mouseover(function() {
         this.fireMouseover();
      }.bind(this));
    }
  });
});