我创建了自定义控制器,它扩展了
sap.ui.commons.ValueHelpField
我想覆盖valueHelpRequest事件,但我无法覆盖该方法。我像方法一样压倒事件。任何人都可以告诉我如何覆盖事件
答案 0 :(得分:0)
这是使用ValueHelpField的常规方法。
// create a default ValueHelpField
var oVHF1 = new sap.ui.commons.ValueHelpField('VHF1',{
value: "default",
tooltip: "This is a tooltip",
valueHelpRequest: function(){alert('ValueHelpRequest fired');}
}).placeAt("sample1");
valueHelpRequest事件具有要触发的用户定义函数。如果您想要的自定义可以在事件处理函数中,那么您不需要覆盖事件实现。
否则,如果您想更改触发事件的方式,请参阅以下内容:
对于每个事件'xyz',会生成相应的'fireXyz'方法,该方法应在本地浏览器事件上调用,如'click'等。
浏览器事件应在Control实现中处理,例如'onclick'用于'click','ontap'用于'tap'......
在ValueHelpField控件中,fireValueHelpRequest方法在浏览器事件上调用,例如'click'和'sapshow',即来自方法'onclick'和'onsapshow'。
如果您想要自定义行为,请覆盖方法'onclick'和'onsapshow',检查当前实现,并根据需要添加自定义。
希望它有所帮助。
答案 1 :(得分:0)
sap.ui.core.Control.extend(" nabisoft.bookstore.controls.Book",{
// the control API:
metadata : {
properties : {
//some properties
},
aggregations : {
//some aggregation
},
associations: {
//some association
},
events : {
valueHelpRequest: function(e){
alert("clicked");
}
}
},
答案 2 :(得分:0)
sap.ui.commons.ValueHelpField.extend("HoverButton", {
metadata: {
events: {
"hover" : {}
}
},
onmouseover : function(evt) {
this.fireHover();
},
renderer: {}
});
var myControl = new HoverButton("myBtn", {
text: "Hover Me",
hover: function(evt) {
alert("Button " + evt.getSource().getId() + " was hovered.");
}
});
myControl.placeAt("content");
var myControl = new HoverButton("myBtn", {
text: "Hover Me",
hover: function(evt) {
alert("Button " + evt.getSource().getId() + " was hovered.");
}
});
myControl.placeAt("content");