javascript - SAPUI5: Handle click events properly - Stack Overflow

I am using the SAPUI5 control GenericTile and added both headerImage and click event. When this icon is

I am using the SAPUI5 control GenericTile and added both headerImage and click event. When this icon is clicked, the event handler of the tile is triggered first so that I am not able to react on the icon click itself (which should perform another action of course).

var oGenericTile = new sap.suite.uimons.GenericTile({
                frameType: "TwoByOne",
                header: "My HEader",
                headerImage: "sap-icon://settings",
                tileContent: oTileContent
            });

oGenericTile._oImage.attachPress(function(oEvent) {
                sap.m.MessageToast.show("Icon has been pressed");
                oEvent.cancelBubble();
                oEvent.preventDefault();
            });

            oGenericTile.attachPress(function() {
                sap.m.MessageToast.show("I am always triggered first!!!   :-(");
            });`

Any idea how I can avoid this?

I am using the SAPUI5 control GenericTile and added both headerImage and click event. When this icon is clicked, the event handler of the tile is triggered first so that I am not able to react on the icon click itself (which should perform another action of course).

var oGenericTile = new sap.suite.ui.mons.GenericTile({
                frameType: "TwoByOne",
                header: "My HEader",
                headerImage: "sap-icon://settings",
                tileContent: oTileContent
            });

oGenericTile._oImage.attachPress(function(oEvent) {
                sap.m.MessageToast.show("Icon has been pressed");
                oEvent.cancelBubble();
                oEvent.preventDefault();
            });

            oGenericTile.attachPress(function() {
                sap.m.MessageToast.show("I am always triggered first!!!   :-(");
            });`

Any idea how I can avoid this?

Share Improve this question edited Dec 17, 2021 at 21:43 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Jan 28, 2015 at 8:38 AntonSackAntonSack 1,0472 gold badges27 silver badges50 bronze badges 1
  • 1 You need to extend sap.suite.mons.GenericTile with your own control, i.e. my.GenericTile and override my.GenericTile.prototype.onclick/ontapstart method. – Nikolay Nadorichev Commented Jan 28, 2015 at 10:46
Add a ment  | 

1 Answer 1

Reset to default 1

you could e.g. also cancel the event on the tile manually in order to avoid this behavior... you'd just need to track whether the icon has been pressed, see a simplified example on JSBin: http://jsbin./daqifomoge/3/edit

Extending existing controls and overriding methods always bears the potential to break things when the original control gets an update from the developers...

Maybe there's a more elegant way to do it, though.

Best, Christiane

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745550806a4632569.html

相关推荐

  • javascript - SAPUI5: Handle click events properly - Stack Overflow

    I am using the SAPUI5 control GenericTile and added both headerImage and click event. When this icon is

    11小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信