AmendHub

Download:

jcs

/

wallops

/

amendments

/

123

util: Use ModalDialogFilter for all dialogs, outline ok button there

Rather than manually outlining before calling ModalDialog, do the
outline in response to ModalDialogFilter getting an updateEvt.
 
This ensures standard outline-default-button behavior and draws it
at the proper time.

jcs made amendment 123 about 1 month ago
--- util.c Tue Sep 17 22:03:26 2024 +++ util.c Fri Sep 20 20:58:32 2024 @@ -699,10 +699,8 @@ vwarn(short alert_func, const char *format, va_list ap ShowWindow(dialog); - GetDItem(dialog, ok, &itype, &okhandle, &irect); for (;;) { - outline_button((ControlHandle)okhandle); - ModalDialog(0, &hit); + ModalDialog(ModalDialogFilter, &hit); if (hit == ok) break; } @@ -773,9 +771,7 @@ ask(const char *format, ...) Rect bounds; WindowPtr win, dialog; va_list ap; - Handle ihandle; - Rect irect; - short hit, itype; + short hit; GetPort(&win); @@ -795,10 +791,8 @@ ask(const char *format, ...) (WindowPtr)-1L, false, 0, ask_ditl_h); ShowWindow(dialog); - GetDItem(dialog, ok, &itype, &ihandle, &irect); for (;;) { - outline_button((ControlHandle)ihandle); - ModalDialog(0, &hit); + ModalDialog(ModalDialogFilter, &hit); if (hit == 1 || hit == 2) break; } @@ -1737,10 +1731,22 @@ pascal bool ModalDialogFilter(DialogPtr dlg, EventRecord *event, short *hit) { WindowPtr event_win; - short event_in; + short event_in, itype; char key; + ControlHandle ihandle; + Rect irect; switch (event->what) { + case nullEvent: + /* + * TODO: support passing this through to a function the caller + * can specify to do something while we're staying modal + */ + break; + case updateEvt: + GetDItem(dlg, ok, &itype, &ihandle, &irect); + outline_button(ihandle); + break; case mouseDown: event_in = FindWindow(event->where, &event_win);