Hi Kenny, Kenneth Tilton wrote: > > Alexander Back wrote: >> Hi Kenny, >> >> Kenneth Tilton wrote: >>> I listen to "changeSelected" on a Tabview to keep track of who is in >>> front. Works well except on app start-up, where it appears the initial >>> "changeSelected" gets kicked off before the selected page's structure >>> has been finalized. >> I've just tested a tabView widget with several pages at the playground >> and I get only one call of the event listener at startup and the rest is >> working as expected. > > Yes, I only get one call on startup, but at that call the page returned > by getSelected has two children (so I suspect the page returned by > getData will be the same page and so I'll still see two children). Yes, both return the same value - the selected tabview page.
> I'm OK, I just threw in a hack to always take the last child. :) But if > "changeSelected" is being called before the widget is ready, folks may > run into other problems eventually. Yes, I also ran into that problem. The thing is that you have to add the "changeSelected" listener *after* you added the pages. --snip-- var tabView = new qx.ui.tabview.TabView; var tabPage1 = new qx.ui.tabview.Page("Page1"); var tabPage2 = new qx.ui.tabview.Page("Page2"); tabView.add(tabPage1); tabView.add(tabPage2); tabPage1.setLayout(new qx.ui.layout.HBox); tabPage1.add(new qx.ui.basic.Atom("Test")); // Document is the application root var doc = this.getRoot(); // Add button to document at fixed coordinates doc.add(tabView, { left : 100, top : 50 }); tabView.addListener("changeSelected", function(e){ console.debug(this.getChildren()); }); --snip-- If you add the listener right after you created the "tabView" widget then the listener will be informed when a new page is added. Since no page is existent at all this new page gets selected as default - and the listener gets called. The second page will simply added withou being selected and thus the listener is not called. In short: If you want only monitor the changes of the user you have to add the listener at last. cheers, Alex >>> The logging/working listener code is this: >>> >>> tabView.addListener("changeSelected", function (e) { >>> pg = tabView.getSelected(); >>> console.log("app tabview changesel PAGE " + pg ); >>> console.log("app tabview pg childs " + pg.getChildren()); >>> mod = pg.getChildren()[0]; >>> console.log("app tabview changesel PAGE child" + mod); >>> console.log("app tabview changesel frontns now: "+ mod.ns); >>> >>> frontNS=mod.ns; // the real code >>> }) >> If you use the "changeSelected" event you can use >> >> --snip-- >> tabView.addListener("changeSelected", function(e){ >> var selectedTabViewPage = e.getData(); >> }); >> --snip-- >> >> the "getData()" method to access the currently selected tabView page >> instance. >> >> cheers, >> Alex >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> SourcForge Community >> SourceForge wants to tell your story. >> http://p.sf.net/sfu/sf-spreadtheword >> _______________________________________________ >> qooxdoo-devel mailing list >> qooxdoo-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel >> >> > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > qooxdoo-devel mailing list > qooxdoo-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel -- Alexander Back Core Development::Webtechnologies alexander.b...@1und1.de fon +49 721 91374 8047 http://www.1und1.de 1&1 Internet AG Ernst-Frey-Straße 9 76135 Karlsruhe Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas Gottschlich, Robert Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver Mauss, Jan Oetjen Aufsichtsratsvorsitzender: Michael Scheeren Amtsgericht Montabaur / HRB 6484 ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel