diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-14 12:15:03 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-14 12:15:03 +0300 |
commit | 01ca3e00909d1ad2bf6346052b00f360b28b8b1f (patch) | |
tree | bc3c979f6d4c4e31631cb73e4ee487e2c3b9e10e | |
parent | 9981de5692c358411304a03c767408cf6ebeb770 (diff) |
Menu cancel action is only enabled when menu shown
-rw-r--r-- | src/ui/util.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index 36fd91eb..1d14ec99 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -189,7 +189,9 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | |||
189 | } | 189 | } |
190 | addChild_Widget(parent, iClob(menu)); | 190 | addChild_Widget(parent, iClob(menu)); |
191 | setCommandHandler_Widget(menu, menuHandler_); | 191 | setCommandHandler_Widget(menu, menuHandler_); |
192 | addAction_Widget(menu, SDLK_ESCAPE, 0, "cancel"); | 192 | iWidget *cancel = addAction_Widget(menu, SDLK_ESCAPE, 0, "cancel"); |
193 | setId_Widget(cancel, "menu.cancel"); | ||
194 | setFlags_Widget(cancel, disabled_WidgetFlag, iTrue); | ||
193 | return menu; | 195 | return menu; |
194 | } | 196 | } |
195 | 197 | ||
@@ -198,6 +200,7 @@ void openMenu_Widget(iWidget *d, iInt2 coord) { | |||
198 | postCommand_App("cancel"); /* dismiss any other menus */ | 200 | postCommand_App("cancel"); /* dismiss any other menus */ |
199 | processEvents_App(postedEventsOnly_AppEventMode); | 201 | processEvents_App(postedEventsOnly_AppEventMode); |
200 | setFlags_Widget(d, hidden_WidgetFlag, iFalse); | 202 | setFlags_Widget(d, hidden_WidgetFlag, iFalse); |
203 | setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iFalse); | ||
201 | arrange_Widget(d); | 204 | arrange_Widget(d); |
202 | d->rect.pos = coord; | 205 | d->rect.pos = coord; |
203 | /* Ensure the full menu is visible. */ | 206 | /* Ensure the full menu is visible. */ |
@@ -224,6 +227,7 @@ void openMenu_Widget(iWidget *d, iInt2 coord) { | |||
224 | 227 | ||
225 | void closeMenu_Widget(iWidget *d) { | 228 | void closeMenu_Widget(iWidget *d) { |
226 | setFlags_Widget(d, hidden_WidgetFlag, iTrue); | 229 | setFlags_Widget(d, hidden_WidgetFlag, iTrue); |
230 | setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iTrue); | ||
227 | refresh_App(); | 231 | refresh_App(); |
228 | } | 232 | } |
229 | 233 | ||