Mercurial > projects > mde
comparison mde/gui/widget/PopupMenu.d @ 133:9fd705793568
Fixed menu popup bug, improved recursion detection.
Menu popups can now determine whether or not they are sub-menus.
Recursion detection can now also check content (if not the same, there's not a risk of infinite recursion).
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 23 Jan 2009 16:05:05 +0000 |
parents | 9cff74f68b84 |
children | 9f035cd139c6 |
comparison
equal
deleted
inserted
replaced
132:264028f4115a | 133:9fd705793568 |
---|---|
49 adapter.getDimensions (mw, mh); | 49 adapter.getDimensions (mw, mh); |
50 w = mw; | 50 w = mw; |
51 h = mh; | 51 h = mh; |
52 } | 52 } |
53 | 53 |
54 override void recursionCheck (widgetID wID, IContent c) { | |
55 if (wID is id && c is content) | |
56 throw new WidgetRecursionException (wID); | |
57 parent.recursionCheck (wID, c); | |
58 } | |
59 | |
54 override int clickEvent (wdabs, wdabs, ubyte b, bool state) { | 60 override int clickEvent (wdabs, wdabs, ubyte b, bool state) { |
55 if (b == 1 && state == true) { | 61 if (b == 1 && state == true) { |
56 if (!pushed) { | 62 if (!pushed) { |
57 parentIPPW.addChildIPPW (this); | 63 parentIPPW.addChildIPPW (this); |
58 parentIPPW.menuActive = true; | 64 parentIPPW.menuActive = true; |
59 mgr.positionPopup (this, popup); | 65 mgr.positionPopup (this, popup); |
60 pushed = true; | 66 pushed = true; |
61 } else { | 67 } else if (!parentIPPW.parentMenuActive) { // if not a submenu |
62 // NOTE: perhaps shouldn't do anything when | |
63 // parentIPPW.parentIPPW.menuActive | |
64 // (this causes funny behaviour when clicking a submenu): | |
65 parentIPPW.removeChildIPPW (this); | 68 parentIPPW.removeChildIPPW (this); |
66 } | 69 } |
67 } | 70 } |
68 return 0; | 71 return 0; |
69 } | 72 } |
75 | 78 |
76 override void underMouse (bool state) { | 79 override void underMouse (bool state) { |
77 if (state && !pushed && parentIPPW.menuActive) { | 80 if (state && !pushed && parentIPPW.menuActive) { |
78 parentIPPW.addChildIPPW (this); | 81 parentIPPW.addChildIPPW (this); |
79 menuActive = true; | 82 menuActive = true; |
80 mgr.positionPopup (this, popup, 1); // causes redraw | 83 mgr.positionPopup (this, popup, |
84 parentIPPW.parentMenuActive ? 1 : 0); | |
81 pushed = true; | 85 pushed = true; |
82 } | 86 } |
83 } | 87 } |
84 | 88 |
85 override void draw () { | 89 override void draw () { |