controls/TabControl: Modifications to solve Cartographer's styles editor issues glab
authorJerome St-Louis <jerome@ecere.com>
Fri, 4 Sep 2015 07:42:39 +0000 (15:42 +0800)
committerJerome St-Louis <jerome@ecere.com>
Thu, 15 Oct 2015 00:23:01 +0000 (20:23 -0400)
ecere/src/gui/controls/TabControl.ec

index aa5dfa5..94a7cc1 100644 (file)
@@ -540,12 +540,12 @@ public class TabControl : Window
 
    bool NotifyClicked(Button button, int x, int y, Modifiers mods)
    {
-      if(curTab == (Tab)(intptr)button.id)
+      if(curTab == (Tab)(intptr)button.id && curTab.created)
          return true;
       //curButton.Activate();
       curButton.MakeActive();
 
-      if(curTab.Destroy(0))
+      if(!curTab || curTab == (Tab)(intptr)button.id || curTab.Destroy(0))
       {
          curButton.checked = false;
          button.checked = true;
@@ -638,18 +638,21 @@ public class TabControl : Window
                }
                break;
             }
-            else
+            else if(button.created)
                fallbackTab = button.tab;
          }
       }
-      if(curTab == tab)
+      if(curTab == tab && curTab.created)
       {
          if(!fallbackTab)
             fallbackTab = tabButtons.children.first ? ((TabButton)tabButtons.children.first).tab : null;
-         if(fallbackTab)
+         if(fallbackTab && fallbackTab.button.created)
             fallbackTab.SelectTab();
          else
+         {
+            curTab.Destroy(0);
             curTab = null;
+         }
          /*curTab = fallbackTab;
          curButton = curTab.button;
          curButton.checked = true;
@@ -750,6 +753,11 @@ public class Tab : Window
       button.NotifyClicked(button.master, button, 0, 0, 0);
    }
 
+   public property bool isAdded
+   {
+      get { return button && button.created; }
+   }
+
    watch(caption)
    {
       if(button)