MUIV_Application_ReturnID_Quit question

5 posts / 0 new
Last post
trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
MUIV_Application_ReturnID_Quit question

I have a question concerning MUIV_Application_ReturnID_Quit in MUI. The autodoc says that "the ideal input loop for an object oriented MUI application" should look like this:

  1. {
  2. ULONG sigs = 0;
  3.  
  4. while (DoMethod(app,MUIM_Application_NewInput,&sigs)
  5. !=MUIV_Application_ReturnID_Quit)
  6. {
  7. if (sigs)
  8. {
  9. sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  10. if (sigs & SIGBREAKF_CTRL_C) break;
  11. }
  12. }
  13. }

The input loop ends when the MUIM_Application_NewInput method says that the program shall terminate (e.g. upon receiving a window close event). Having no previous experience with MUI, I'd like to know how quit confirmation (such as displaying an "Are you sure?" requester) is best handled, after MUIV_Application_ReturnID_Quit breaks the input loop.

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
This should look familiar to

This should look familiar to a ReAction coder:

  1. BOOL done = FALSE;
  2. ULONG mui_sigs = 0;
  3. ULONG other_sigs = whatever;
  4.  
  5. while (!done)
  6. {
  7. ULONG sigs_recvd = 0;
  8.  
  9. if (mui_sigs)
  10. sigs_recvd = Wait (mui_sigs | other_sigs | SIGBREAKF_CTRL_C);
  11.  
  12. if (sigs_recvd & SIGBREAKF_CTRL_C)
  13. {
  14. Printf ("*** Break\n");
  15. done = TRUE;
  16. }
  17.  
  18. if (sigs_recvd & other_sigs)
  19. {
  20. handle_other_things();
  21. }
  22.  
  23. switch (DoMethod (app,MUIM_Application_NewInput,&sigs))
  24. {
  25. case ideally_here_should_be_nothing_but_you_never_know:
  26. handle_this();
  27. break;
  28. case MUIV_Application_ReturnID_Quit:
  29. if (are_you_sure())
  30. done = TRUE;
  31. break;
  32. }
  33. }

Note: I've written this from memory. I'll look up real existing (and working) MUI code of mine tomorrow.

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: MUIV_Application_ReturnID_Quit question

I'll look up real existing (and working) MUI code of mine tomorrow.

Thank you Thomas, really appreciated!

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

kas1e
kas1e's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2010-11-30 15:30
@Trixie Not related to what

@Trixie
Not related to what you ask exactly, but still about "ideal mui loop": year ago i ask Thore to implement MUIM_Application_Execute() to make AROS code be more easy portable (that function come from AROS's ZUNE), and so he add it, and in changelog it stated as "* Application.c: added the method MUIM_Application_Execute which implements the ideal main loop for an MUI application". The code of that MUIM_Application_Execute (at least on AROS), are:

  1. IPTR Application_Execute(Class *CLASS, Object *self, Msg message)
  2. {
  3.     ULONG signals = 0L;
  4.     
  5.     while
  6.     (
  7.            DoMethod(self, MUIM_Application_NewInput, (IPTR) &signals)
  8.         != MUIV_Application_ReturnID_Quit
  9.     )
  10.     {
  11.         if (signals)
  12.         {
  13.             signals = Wait(signals | SIGBREAKF_CTRL_C);
  14.             if (signals & SIGBREAKF_CTRL_C) break;
  15.         }
  16.     }
  17.     
  18.     return NULL;
  19. }

And so you can just use now in our mui that MUIM_Application_Execute() directly, something like:

  1. main()
  2. {
  3.    ..balbala..
  4.  
  5.    SET(win, MUIA_Window_Open, TRUE);
  6.    DoMethod(app, MUIM_Application_Execute);
  7.  
  8.    ... blablabla....
  9. }
salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
Combining thomas' and kas1e's

Combining thomas' and kas1e's code you could do:

  1. BOOL done = FALSE;
  2. do {
  3. DoMethod(app, MUIM_Application_Execute);
  4. } while (!are_you_sure());
Log in or register to post comments