Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12821] iOS: Feature View event e source is not enough, consider e.owner

GitHub Issuen/a
TypeNew Feature
Priorityn/a
StatusReopened
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsaddeventlistener, event
ReporterSameeh Harfoush
AssigneeUnknown
Created2013-02-04T11:21:54.000+0000
Updated2018-02-28T20:03:29.000+0000

Description

If i have two views one inside the other and you put a click EventListener on the topmost parent view, the e.source will reference the child view if it fires and bubbles to the parent click event. there must be a property that reference the object that the EventListener was called upon, something like e.owner. e.owner will reference the view that has an addEventListener

Comments

  1. Eduardo Gomez 2013-02-18

    Hello Sameeh, In order to get a better understanding about this Feature request, I come up with a simple sample. Just added a simple property such as an ID value (parent view) which is generally OK. Typically is widely implemented to set IDs on your objects and check the id in the click event to determine which object was clicked (if you have more than one).
       var win = Ti.UI.createWindow({
           orientationModes: [ Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT ],
           layout: "absolute"
       });
        
       var iAdView = Ti.UI.createView({
           bottom: "0px",
           height: "500",
           width: "500",
           backgroundColor: "gray"
       });
       var childView = Ti.UI.createView({
       	height: '25',
       	width: Ti.UI.FILL,
       	backgroundColor: 'red',
       	owner: iAdView
       });
       iAdView.add(childView);
       
       iAdView.addEventListener("click", function (e) {
           if(null != e.source.owner){
           	alert( JSON.stringify(e) );
           	Ti.API.info(" e.source: "+ e.source.owner );    	
           }
       });
        
       win.add(iAdView);
       win.open();
       
    Being said, can you elaborate why wouldn't be sufficient to get around this functionality? Hope hearing from you soon, thanks.
  2. Eduardo Gomez 2013-02-21

    Closing due to inactivity.
  3. Sameeh Harfoush 2013-02-22

    the above example is exactly the same workaround i used in the beginning and it works. but if you have complex parent/child UI, the above approach gets annoying and you end up keeping track of many parent/ child variable reference. thanks anyway.
  4. Eduardo Gomez 2013-02-22

    Thanks Sameeh, that is what I thought. Moved to main project, to dig into, review tech implications and further feasibility.
  5. Sameeh Harfoush 2013-09-16

    hello Eduardo, are you guys still planning to consider the "e.owner" feature?

JSON Source