Ask Reuben
User Action Feedback
The User clicked a button but “nothing” happens?
A core property of the Front-End protocol is that the synchronization of the User Interface occurs when the runtime next asks for some user interaction. If the runtime is doing some processing, there will be no update of the user interface until the next piece of user interaction, that is when the processing finishes. This has some implications for processes that take a number of seconds to process. One such gotcha is the case where the user clicks on a warning “Are you sure you want to do this?” dialog before some processing. Consider the following small example … … if the user clicks “Yes” in the warning dialog, the warning dialog remains visible whilst the processing occurs.
MAIN
DEFINE ok BOOLEAN
MENU "Warning" ATTRIBUTES(STYLE="dialog",COMMENT="Are you sure?")
ON ACTION no ATTRIBUTES(TEXT="No")
LET ok = FALSE
ON ACTION yes ATTRIBUTES(TEXT="Yes")
LET ok = TRUE
END MENU
IF ok THEN
SLEEP 3
MENU "Finish" ATTRIBUTES(STYLE="dialog",COMMENT="Finished, Press OK to continue")
ON ACTION ACCEPT
EXIT MENU
END MENU
END IF
END MAIN
The user can interpret this as meaning they have not clicked on the dialog and sometimes will click the dialog again and again. If they are unlucky, when the processing has finished another dialog may appear and they may find themselves unwittingly clicking something in this next dialog. If they have used the keyboard, some extra strokes are being added to the keyboard buffer to be executed unexpectedly when the processing finishes.
This is one of the few occasions where the use of ui.Interface.Refresh() is justified. In this example, add a CALL ui.Interface.refresh()
after the END MENU
and before the SLEEP 3
. This will force the screen to be redrawn at this point, that is redrawn without the warning dialog.
Whilst we discourage overuse of ui.Interface.refresh(), it could be justified having a coding standard to have a ui.Interface.refresh() immediately after every END MENU (where style=dialog), or after CLOSE WINDOW of a modal window, so that these places where the user performs an action, the user gets feedback in the form of the dialog/window closing and they are aware that the click has been recognised by the computer and it is doing something.