Modal window in BASIC
François Vanzeveren (2221) 241 posts |
Hi, I would like to display a modal window in BASIC. By modal, I mean: Actually, I would like to reproduce the command "MESSAGE"from WimpWorks, which returns the choice of the user (i.e. the button clicked). Using “SYS Wimp_OpenWindow” does not prevent the user to leave the window and do whatever he wants… I have an “error” window defined in a Templates file I loaded first that I want to use the modal window. Thank you for your help. Regards Fançois |
Andrew Rawnsley (492) 1445 posts |
There may be better ways, but the way that comes to mind is to use MOUSE RECTANGLE command (I think that’s the BASIC command – it’s 20 years since I used it!) to define the window boundaries as the mouse area. This wouldn’t affect multitasking, but would restrict the user to your window. Also, remember to reset it back to fullscreen once the window closes. And, erm, make sure the window isn’t moveable (window flags) otherwise you could have some real fun and games! Edit – generally speaking, though, I suspect the style guide would frown on apps restricting mouse pointer unless the error was so significant that doing anything else would be fatal. Otherwise, there’s no way to use other programs to salvage things – for example, if you can move the mouse, you could use Zap/StrongEd to dump workspace to extract potentially-lost data. If you restrict mouse, you are essentially saying "this error is so fatal that unless you click on an action, anything else might result in total data loss, or a full system crash. |
Raik (463) 2061 posts |
Nor sure, will you report an “error” or give a “message”? |
François Vanzeveren (2221) 241 posts |
Hi all Thank you for the feedback. After some thought, I indeed believe modal dialog box is not good practice when informing the user he did not properly filled some fields. For serious error, there is SYS_ReportError which should do the job. Regards |
Rick Murray (539) 13840 posts |
You can pop open your own dialogue box and keep your application running (but it’ll need an interlock mechanism so your app is ‘frozen’ until the dialogue is dismissed). What you shouldn’t do is constrain the mouse pointer to your window, because there are so many ways to mess it up (Alt-Tab to bring a new app to the front, pressing F12 then Return, etc). ReportError will do the job but at the cost of freezing the entire Desktop. It’s a lazy way to give messages (says a person who does exactly that…!). Make sure that pressing ESC is always the ‘safe’ option, because those of us with machines that run unattended may be running a module to automatically dismiss the error box after n seconds (usually 3-5) and the traditional way of doing that is to simulate the ESC key being pressed. |
Andrew Rawnsley (492) 1445 posts |
Funnily enough, I ended up writing a similar window in C for PineTools this afternoon. I didn’t make it restrict mouse – I just made sure to open it centered on the mouse pointer, with input focus (wimp_setcaret). Setting focus back to the main window checked for the popup, and closed it. I also have a similar, non-interactive “message” window which I include in almost all my programs. This opens a window with a user-defined message for a specified period of time and then closes it. Clicking the window dismisses it immediately. I make sure to include an icon field to the left of the window that is set per-application, so that the user can identify which application popped up the message (by the icon, plus it looks prettier). |
Steve Pampling (1551) 8170 posts |
Like an awful lot of the application error boxes that pop up and move you mouse position into their pop up window. You cancel, the program continues and immediately generates the same error. I seem to recall a discussion about built in, OS wide, logging systems1 that used multitasking pop ups for the notification — with a configurable status for the pop up of user response, auto dismiss with default or user specified timeout, and there’s auto dismiss if the problem cleared. Since all versions would log the error to a file there’s always something to send to the developer(s) 1 Despite having slept many times since I last said anything on the subject I still recall the basic options discussed and even thought of a new variant. |
Alan Adams (2486) 1149 posts |
And having made use of this today, I can report that the description in the BASIC VI printed manual is different from the reality in BASIC V. The manual says the parameters are left, bottom, right, top. Usefully, when writing programs using this (and in the case where for whatever reason you cannot get out of the window) Alt-break, then Cancel restores full-screen mouse movement. And before anyone jumps up to say this is the wrong approach, in this case it is used to open a “fix it” window when an error is detected, and selecting a button within the window corrects the error and closes the window. |