changeset 423:8558b2219688

Improve multi-modal hirarchy behavior (but not very usefully)
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 17 Sep 2011 17:51:21 +0200
parents 78c32a77ef43
children ba6faea9929f
files mamba/habitats/editor.py mamba/widgets/base.py
diffstat 2 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mamba/habitats/editor.py	Sat Sep 17 17:17:59 2011 +0200
+++ b/mamba/habitats/editor.py	Sat Sep 17 17:51:21 2011 +0200
@@ -317,7 +317,8 @@
             message = MessageBox((300, 300),
                     'Unable to change tileset:: %s' % error,
                     self.refresh_display, color='red')
-            self.display_dialog(message)
+            widget.parent.add(message)
+            message.grab_focus()
             return True
         self.container.paused = False
         self.clear_toolbar()
--- a/mamba/widgets/base.py	Sat Sep 17 17:17:59 2011 +0200
+++ b/mamba/widgets/base.py	Sat Sep 17 17:51:21 2011 +0200
@@ -47,10 +47,7 @@
         if self.focussable:
             # Find the root and current focus
             root = self
-            this_modal_base = None
             while root.parent is not None:
-                if root.modal and this_modal_base is None:
-                    this_modal_base = root
                 root = root.parent
             focus = root
             focus_modal_base = None
@@ -60,9 +57,15 @@
                     focus_modal_base = focus
                 focus = focus.children[focus.focussed_child]
 
-            # Don't leave a modal Widget
-            if focus_modal_base and focus_modal_base != this_modal_base:
-                return False
+            # Don't leave a modal heirarchy
+            if focus_modal_base:
+                widget = self
+                while widget.parent is not None:
+                    if widget == focus_modal_base:
+                        break
+                    widget = widget.parent
+                else:
+                    return False
 
             root.defocus()
             widget = self