Mercurial > projects > dynamin
diff dynamin/gui/control.d @ 50:a18c2fd9fe36
Fix a crash if Control.focus was called on a Control not in a Window.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Tue, 04 Aug 2009 20:41:43 -0500 |
parents | 62742ce025ec |
children | d5823ccfddc6 |
line wrap: on
line diff
--- a/dynamin/gui/control.d Tue Aug 04 20:39:03 2009 -0500 +++ b/dynamin/gui/control.d Tue Aug 04 20:41:43 2009 -0500 @@ -304,10 +304,10 @@ void focus() { if(!_focusable) return; - Control c = this; - while(c.parent) - c = c.parent; - if(auto win = cast(Window)c) { + auto top = getTopLevel(); + if(!top) + return; + if(auto win = cast(Window)top) { if(win.focusedControl) { win.focusedControl._focused = false; win.focusedControl.repaint();