All pastes #1680367 Raw Edit

back event propagation

public javascript v1 · immutable
#1680367 ·published 2009-11-21 01:50 UTC
rendered paste body
// I have a webview filling the screen and want to associate the back gesture with browsing back in the history, unless we cannot go back// in which case the event should bubble.// in app/assistants/Guide-assistant.js// this.canGoBack is true when the webview can go back, and is being set properly (I have triple checked)GuideAssistant.prototype.handleCommand = function(event) {    Mojo.Log.info('[GuideAssistant.handleCommand] event.type = ', event.type, ', event.command = ', event.command);    if (event.type == Mojo.Event.back) {	Mojo.Log.info('Mojo.Event.back ... canGoBack = ', this.canGoBack);	if (this.canGoBack) {	    Mojo.Log.info('going back');	    this.webView.mojo.goBack();	    event.stopPropagation();	}    }}// in app/assistants/stage-assistant.jsStageAssistant.prototype.handleCommand = function(event) {    Mojo.Log.info('[StageAssistant.handleCommand] event.type = ', event.type, ', event.command = ', event.command);    if (event.type == Mojo.Event.back && event.canceled) {	Mojo.Log.info('handling canceled back event');	event.stopPropagation();	event.cancelBubble = true;	event.bubbles = false;    }    else if (event.type == Mojo.Event.back) {	Mojo.Log.info('handling normal back event');    }    else	Mojo.Log.info('event.type = ', event.type, ', event.command = ', event.command);}// The mysterious bit is that the event doesn't bubble up to the stage assistant, but does bubble as something else handles it. app controller?// Can I mess with the command chain in controllers?