Skip to content

Commit

Permalink
Merge pull request #710 from pingwang2011/timob-6096
Browse files Browse the repository at this point in the history
Timob 6096: Android: View: Rhino only: Event propagation not showing window info when clicking anywhere
  • Loading branch information
billdawson committed Nov 18, 2011
2 parents 4e60c8b + fdd0196 commit b423f70
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions android/modules/ui/src/js/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,18 @@ exports.bootstrapWindow = function(Titanium) {
if ("url" in this._properties) {
this.loadUrl();
}


// Set view and model listener after the window opens
this.setWindowView(this.view);

// Add event listeners and update the source of events after the window opens
for (var event in this._events) {
var listeners = this.listeners(event);
for (var i = 0; i < listeners.length; i++) {
this.addWrappedListener(event, listeners[i]);
}
}

this.currentState = this.state.opened;
this.fireEvent("open");
}
Expand All @@ -244,7 +254,7 @@ exports.bootstrapWindow = function(Titanium) {

kroll.log(TAG, "Loading window with URL: " + this.url);

// Reset creationUrl of the window based on this._sourceUrl and this.url
// Reset creationUrl of the window
var currentUrl = url.resolve(this._sourceUrl, this.url);
this.window.setCreationUrl(currentUrl.href);

Expand Down Expand Up @@ -356,9 +366,20 @@ exports.bootstrapWindow = function(Titanium) {
EventEmitter.prototype.addEventListener.call(this, event, listener);

} else {
this.window.addEventListener(event, listener);
this.addWrappedListener(event, listener);
}
}

// Add event listener to this.window and update the source of event to this.
Window.prototype.addWrappedListener = function(event, listener) {
var self = this;
self.window.addEventListener(event, function(e) {
if (e.source == self.window) {
e.source = self;
}
listener(e);
});
}

Window.prototype.removeEventListener = function(event, listener) {
if (["open", "close"].indexOf(event) >= 0 || this.window == null) {
Expand Down

0 comments on commit b423f70

Please sign in to comment.