Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TabDeselectEvent.cancel behavior

    In short, it seems that calling TabDeselectedEvent.cancel() in a TabDeslectedHandler causes the event to be fired again - once on Firefox 11 and twice on IE9. See the following for a test case tried with 3.0p 2012-06-08 and 3.1p 2012-06-28.

    Bug?

    Code:
    public void onModuleLoad() {
    		
    		VLayout layout = new VLayout();
    		layout.setWidth100();
    		layout.setHeight100();
    
    		final TabSet tabset = new TabSet();
    		Tab t1 = new Tab("Tab 1");
    		Tab t2 = new Tab("Tab 2");
    		
    		TabDeselectedHandler td = new TabDeselectedHandler() {
    			public void onTabDeselected(TabDeselectedEvent event) {
    				GWT.log(event.getTab().getTitle());
    				event.cancel();
    			}
    		};
    		
    		tabset.addTabDeselectedHandler(td);
    		
    		tabset.setTabs(t1, t2);
    		
    		layout.addMember(tabset);
    		
    		layout.draw();
    
    		/*
    		 * enable the sgwt debug console in development mode
    		 */
    		if (!GWT.isScript()) {
    			KeyIdentifier debugKey = new KeyIdentifier();
    			debugKey.setCtrlKey(true);
    			debugKey.setAltKey(true);
    			debugKey.setKeyName("D");
    			Page.registerKey(debugKey, new KeyCallback() {
    				public void execute(String keyName) {
    					SC.showConsole();
    				}
    			});
    		}

    #2
    On 2nd thought, I actually have a handful of problems and this is just one of them. Maybe I'm asking the wrong question.

    What I need to do is save changed data on some tab when some other tab is selected. I think I want to 'suspend' the tab selection/deselection until my save callback fires, allowing the end user to proceed on success, and not on fail.

    What is the best way to do that, if not onTabDeselected?

    Comment


      #3
      Hacking around all this, and I have something that pretty much works with a TabSelectedHandler, but it's kind of a kludge and I still wouldn't mind some feedback here...

      Comment


        #4
        Sorry Bill, this slipped through the cracks..

        This is a tricky area because of focus handling bugs in browsers (especially IE) and because it's not clear what the ideal UI is here (opinions vary).

        If you have something working with slightly warty code, we would basically recommend sticking with what you have.

        Comment


          #5
          A quick update on this.
          We have reworked the code around TabDeselected in the 3.1d branch to avoid the issue where it fires twice.

          We're not planning to port this to 3.0p for now - there's a somewhat fundamental change of approach in the internal code that may not be trivial to move across, so we'd recommend you continue with your current approach (unless you want to upgrade to 3.1d which is due for final release very soon).

          Regards
          Isomorphic Software

          Comment

          Working...
          X