Prevent modal dialog from being dismissed immediately.

This commit is contained in:
Steve 2016-03-04 14:14:45 +00:00
parent 95cb35d5a1
commit d2acbefc6d
1 changed files with 35 additions and 20 deletions

View File

@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "modalDialog.h" #include "modalDialog.h"
static int enableTimer;
static Widget *ok; static Widget *ok;
static Widget *okCancelOK; static Widget *okCancelOK;
static Widget *okCancelCancel; static Widget *okCancelCancel;
@ -38,6 +39,8 @@ void initModalDialog(void)
okCancelCancel = getWidget("cancel", "okCancel"); okCancelCancel = getWidget("cancel", "okCancel");
okCancelCancel->action = NULL; okCancelCancel->action = NULL;
okCancelCancel->isModal = 1; okCancelCancel->isModal = 1;
enableTimer = 0;
} }
void showOKDialog(void (*callback)(void), const char *format, ...) void showOKDialog(void (*callback)(void), const char *format, ...)
@ -55,6 +58,9 @@ void showOKDialog(void (*callback)(void), const char *format, ...)
app.modalDialog.type = MD_OK; app.modalDialog.type = MD_OK;
ok->action = callback; ok->action = callback;
enableTimer = FPS;
ok->enabled = okCancelOK = okCancelCancel = 0;
} }
void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void), const char *format, ...) void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void), const char *format, ...)
@ -73,6 +79,9 @@ void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void),
okCancelOK->action = okCallback; okCancelOK->action = okCallback;
okCancelCancel->action = cancelCallback; okCancelCancel->action = cancelCallback;
enableTimer = FPS;
ok->enabled = okCancelOK = okCancelCancel = 0;
} }
void doModalDialog(void) void doModalDialog(void)
@ -80,6 +89,12 @@ void doModalDialog(void)
doWidgets(); doWidgets();
clearInput(); clearInput();
enableTimer = MAX(enableTimer - 1, 0);
if (!enableTimer)
{
ok->enabled = okCancelOK = okCancelCancel = 1;
}
} }
void drawModalDialog(void) void drawModalDialog(void)