The focus determines which window receives keyboard events. It is managed by the window manager. Sometimes, it is necessary for an application to grab the focus, i.e. require that all input go to this window before proceeding. For example when implementing a window which asks the user to confirm a choice, you do not want to user to start any other interaction, you want them to answer the question. Such a window, which has to answered before the program is allowed to proceed, is called modal.
Grabbing the focus is done with the functions grabLocal or grabGlobal from the module Focus.htmlFocus. A local grab means that the user cannot interact with any other window from the same application; a global grab means that the use cannot interact with any other window. After grabbing the focus, you should return the grab with returnGrab.
Global grabs are dangerous, because if you forget to return the grab (or even worse, your application crashes), the user is effectively frozen out. On the other hand, for example when requiring sensitive information such as passwords or credit card numbers, they are a good idea to keep the user from typing his password into an open chat window.
The toolkit (see Sect. 10) offers the modules ModalDialog.htmlModalDialog and DialogWin.htmlDialogWin which implement modal dialogs, and various oft-used dialog windows.