question about a mobile project behavior

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

question about a mobile project behavior

rsantiagopaz
Hi. I will try to explain a 'problem' that I have. My english is very limited.

I do a simplified example with this little modification to mobile default project (generated with create-application.py). Try this code in a default mobile project, run, go to "Page 2" and press the hardware Back button from a mobile device (or back button from navigator, not back button from qooxdoo's NavigationPage).
This precarious modification is for catch the hardware Back button from a mobile device.

Compiled with "source" this example works fine in Firefox and Chrome. But compiled with "build" works fine only in Firefox. I mean, with Chrome and build, the behavior is different than I expected.
My knownledge in javascript and qooxdoo is limited and I cant understand this behavior change.
Anyone can give me some little help to understand what's happening. Thanks



        this.cancelarback = false;
        window.location.hash = "inicio";
       
        this.hashChange = {widgets: {}, functions: []};
        this.apilarHashChange = qx.lang.Function.bind(function(widget, fnc) {
                if (this.hashChange.widgets[widget] == null) {
                        this.hashChange.widgets[widget] = this.hashChange.functions.length;
                        this.hashChange.functions.push({widget: widget, fnc: fnc});
                }
        }, this);
       
        this.desapilarHashChange = qx.lang.Function.bind(function(widget) {
                var index = this.hashChange.widgets[widget];
                if (index != null) {
                        var item = this.hashChange.functions.pop();
                        this.hashChange.widgets[item.widget] = null;
                        item.fnc();
                }
        }, this);
       
        window.addEventListener("hashchange", qx.lang.Function.bind(function(e){
                if (this.cancelarback) {
                        this.cancelarback = false;
                        window.location.hash = "1";
                        if (this.hashChange.functions.length > 0) {
                                var item = this.hashChange.functions.pop();
                                this.hashChange.widgets[item.widget] = null;
                                item.fnc();
                        }
                } else this.cancelarback = true;
        }, this));
     
     
     
      var page1 = new qx.ui.mobile.page.NavigationPage();
      page1.setTitle("Page 1");
      page1.addListener("initialize", function()
      {
        var button = new qx.ui.mobile.form.Button("Next Page");
        page1.getContent().add(button);

        button.addListener("tap", function() {
          page2.show();
        }, this);
      },this);

      var page2 = new qx.ui.mobile.page.NavigationPage();
      page2.setTitle("Page 2");
      page2.setShowBackButton(true);
      page2.setBackButtonText("Back");
      page2.addListener("initialize", function()
      {
        var label = new qx.ui.mobile.basic.Label("Content of Page 2");
        page2.getContent().add(label);
      },this);
     
     
        page2.addListener("appear", function() {
                this.apilarHashChange(page2, qx.lang.Function.bind(function(){
                        page1.show({reverse:true});
                }, page2));
        }, this);
      page2.addListener("back", function() {
        this.desapilarHashChange(this);
      }, this);
     
     
      // Add the pages to the page manager.
      var manager = new qx.ui.mobile.page.Manager(false);
      manager.addDetail([
        page1,
        page2
      ]);
     
      // Page1 will be shown at start
      page1.show();
Reply | Threaded
Open this post in threaded view
|

Re: question about a mobile project behavior

Daniel Wagner
Administrator
There are several strange things going on here:

* in the source version, the hashchange listener is called once on
application startup even though you register it *after* setting the hash
to "inicio".

* in the build version, the "appear" event for page2 is fired on
application startup. I've opened a report for this:
http://bugzilla.qooxdoo.org/show_bug.cgi?id=7695
Unfortunately, working around this behavior doesn't fix your problem.

* in the build version (Chrome but not Firefox), the hashchange listener
isn't called when the browser's back button is pressed on the second
page. That seems to be the cause of the problem but I have no idea how
to fix it :(

I'll have our mobile framework expert look into this issue, but it'll be
a while before he's back in the office.

Regards,
Daniel

On 28.08.2013 02:18, rsantiagopaz wrote:

> this.cancelarback = false;
> window.location.hash = "inicio";
>
> this.hashChange = {widgets: {}, functions: []};
> this.apilarHashChange = qx.lang.Function.bind(function(widget, fnc) {
> if (this.hashChange.widgets[widget] == null) {
> this.hashChange.widgets[widget] = this.hashChange.functions.length;
> this.hashChange.functions.push({widget: widget, fnc: fnc});
> }
> }, this);
>
> this.desapilarHashChange = qx.lang.Function.bind(function(widget) {
> var index = this.hashChange.widgets[widget];
> if (index != null) {
> var item = this.hashChange.functions.pop();
> this.hashChange.widgets[item.widget] = null;
> item.fnc();
> }
> }, this);
>
> window.addEventListener("hashchange", qx.lang.Function.bind(function(e){
> if (this.cancelarback) {
> this.cancelarback = false;
> window.location.hash = "1";
> if (this.hashChange.functions.length > 0) {
> var item = this.hashChange.functions.pop();
> this.hashChange.widgets[item.widget] = null;
> item.fnc();
> }
> } else this.cancelarback = true;
> }, this));
>
>
>
>        var page1 = new qx.ui.mobile.page.NavigationPage();
>        page1.setTitle("Page 1");
>        page1.addListener("initialize", function()
>        {
>          var button = new qx.ui.mobile.form.Button("Next Page");
>          page1.getContent().add(button);
>
>          button.addListener("tap", function() {
>            page2.show();
>          }, this);
>        },this);
>
>        var page2 = new qx.ui.mobile.page.NavigationPage();
>        page2.setTitle("Page 2");
>        page2.setShowBackButton(true);
>        page2.setBackButtonText("Back");
>        page2.addListener("initialize", function()
>        {
>          var label = new qx.ui.mobile.basic.Label("Content of Page 2");
>          page2.getContent().add(label);
>        },this);
>
>
> page2.addListener("appear", function() {
> this.apilarHashChange(page2, qx.lang.Function.bind(function(){
> page1.show({reverse:true});
> }, page2));
> }, this);
>        page2.addListener("back", function() {
>          this.desapilarHashChange(this);
>        }, this);
>
>
>        // Add the pages to the page manager.
>        var manager = new qx.ui.mobile.page.Manager(false);
>        manager.addDetail([
>          page1,
>          page2
>        ]);
>
>        // Page1 will be shown at start
>        page1.show();

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: question about a mobile project behavior

rsantiagopaz
thanks for your time Wagner. This is the most important question, I need resolve somehow.