Modal and Non-Modal Operations
User-interface objects may be modal or non-modal. An object that is non-modal allows users to interact with other objects outside the object without first having to complete the operation within it. If an object is modal, users are required to complete all interaction within the object before exiting.
Whenever possible, objects should be non-modal. The nature of an event-driven system and mouse navigation encourages the use of non-modal objects. In an event-driven system, users determine the order of events, whereas in a modal environment, the program determines the order of events.
Occasionally, an object must be modal. Modal objects are usually popup objects. Based on some event (e.g., a user presses the save key), a modal object will appear asking a question or a series of questions (e.g., "Save this record?"). Upon completion, the modal object is removed, and the program (as opposed to the user) decides what action to take. Non-modal implies user-driven; modal implies program-driven. Note that while most modal objects will be popup objects, not all popup objects will be modal.
In a DataFlex program (or any event-driven program), the program's user-interface mode will be non-modal most of the time. This user-interface mode is started by executing the Start_UI command, which starts the UI event processor. Events can be key events, mouse events, or timer events. The program runs in this UI mode until it is completed. The last line of most DataFlex programs is a Start_UI command, which starts the UI event processing that will continue until the program terminates.
Occasionally, a modal user-interface event will need to occur on top of this modeless operation.
The purpose of the next section, Creating a Modal Popup Object, is to describe how to handle modal popup objects. This was created to answer the commonly asked question: "While I know how to create complex event-driven views, I do not know how to perform the simple task of popping up a dialog box, asking a question (or questions), and continuing my program based on this response. How do I do this?" This problem could be generalized as, "How do I perform a modal task in a modeless environment?" The solution will be presented in an incremental, tutorial fashion.
If we start with the modal object, we will start in the wrong place. Instead, we must start with the task. You want to perform a task and, based on the outcome of the task, perform some other task. This will be a modal task. Until the task is completed, nothing else should happen. A modal task is program-driven and not user-driven.