Mui, domethod, id and main loop
  • Butterfly
    Butterfly
    rebraist
    Posts: 96 from 2011/4/6
    From: Naples, Italy
    It's surely a noob question: in every skeleton-code i found there's no way to find a "main loop".
    i simply look at a series of "domethod", one after another, to notify between objects or at the best a switch-case where the code switches different ids (#define myroutine 55) to "play" code.
    Is the "main loop" hidden somewhere?
    what numbers can i use to define ids? are there some reserved ids?
    Mac Mini g4 1,5 mos 3.1 registered
    Powerbook g4 1,67 mos 3.1 unregistered
    Sam440 Os4.1.6
    Aros-Aros-Aros.
  • »22.04.11 - 13:40
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Tcheko
    Posts: 510 from 2003/2/25
    From: France
    Because MUI no more uses main loop to handle events.

    The correct way is now subclassing and adding methods. See example classX.c in MUI examples in SDK. This is a good starting point.

    ++
    Quelque soit le chemin que tu prendras dans la vie, sache que tu auras des ampoules aux pieds.
    -------
    I need to practice my Kung Fu.
  • »22.04.11 - 14:00
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 2985 from 2003/3/5
    From: Canada
    It's just like Tcheko said: main loops are a thing of the past when oo programming waasn't very popular on Amiga. It's the same with hooks. So, in order to handle notifications from buttons and so on you subclass Application.mui, Window.mui or some Group.mui of your choice, define your own private methods there and setup notifications on your buttons to call these methods. This lets you keep a neat internal structure rather than having everything in a one huge switch statement.

    To define your own private method and attribute ids you could start with TAG_USER.
  • »22.04.11 - 15:14
    Profile Visit Website
  • Moderator
    Kronos
    Posts: 2240 from 2003/2/24
    Well actually there is small main-loop at the end of every example waiting just for the user to quit, either by closeing the window or hitting CTRL-C.

    Envbrowser.c even has an oldstyle main-loop with input-IDs for every gadget.

    But as allready pointed out notification and subclassing can be very powerfull and leads to better code ..... well atleast if done right ;)
  • »22.04.11 - 17:20
    Profile
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    A MUI program has a main loop, just in the ideal application the loop is empty. I recommend this article, I guess it gives some explanation :-).
  • »22.04.11 - 18:27
    Profile Visit Website