MUI general while() loop issue
  • Order of the Butterfly
    Order of the Butterfly
    r-tea
    Posts: 301 from 2005/3/27
    From: Poland, Zdzies...
    I tried to make a simple digital clock using MUI window, but the result has a strange issue. The method SetAsString, which updates the text gadget displaying clock digits, stops updating right after I deactivate the window and remove the mouse pointer from over the window.
    Below is part of the loop.

    Code:
    		while (running)
    {
    time(&ptr_sec); //// gets data for digital clock
    h = localtime(&ptr_sec)->tm_hour;
    m = localtime(&ptr_sec)->tm_min;
    s = localtime(&ptr_sec)->tm_sec;
    DoMethod(tx_clock, MUIM_SetAsString, MUIA_Text_Contents, "%02d:%02d:%02d", h, m, s);
    Mac mini G4@1,5GHz silent upgrade + Xerox Phaser 3140 + EPSON Perfection 1240U
    Commodore C64C + 2 x 1541II + Datasette + SD-Box

    I miss draggable screens... and do you? I know I'm in a minority unfortunately.
  • »28.02.16 - 19:38
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    pegasos-sigi2
    Posts: 265 from 2006/8/31
    Quote:

    r-tea wrote:
    I tried to make a simple digital clock using MUI window, but the result has a strange issue. The method SetAsString, which updates the text gadget displaying clock digits, stops updating right after I deactivate the window and remove the mouse pointer from over the window.
    Below is part of the loop.

    Code:
    		while (running)
    {
    time(&ptr_sec); //// gets data for digital clock
    h = localtime(&ptr_sec)->tm_hou
    m = localtime(&ptr_sec)->tm_min;
    s = localtime(&ptr_sec)->tm_sec;
    DoMethod(tx_clock, MUIM_SetAsString, MUIA_Text_Contents, "%02d:%02d:%02d", h, m, s);



    At First: Never Write anything in this Loop.
    Use notyfies .
    If you wish to build a clock , use window events and a trigger .
    Read the mui Tutorials in the Sdk.
    Spreedy - The spreedsheet editor of MorphOS
    Calimero - Do you know about the new DTP Program for MorphOS ?
  • »28.02.16 - 20:24
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Tcheko
    Posts: 518 from 2003/2/25
    From: France
    You should give a look at MUI example InputTimer.c in the SDK. It is located in SDK:Examples/MUI/.

    This one is a good start for doing what you're looking for.

    And never tweak the MUI event loop (unless you need to handle signal/msgport outside of MUI).
    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.
  • »28.02.16 - 21:02
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    r-tea
    Posts: 301 from 2005/3/27
    From: Poland, Zdzies...
    Quote:

    Tcheko wrote:
    You should give a look at MUI example InputTimer.c in the SDK. It is located in SDK:Examples/MUI/.




    I have the latest SDK, but there's no such an example you mentioned about. There is InputHandler.c instead. Is this the one?

    [ Edited by r-tea 28.02.2016 - 22:34 ]
    Mac mini G4@1,5GHz silent upgrade + Xerox Phaser 3140 + EPSON Perfection 1240U
    Commodore C64C + 2 x 1541II + Datasette + SD-Box

    I miss draggable screens... and do you? I know I'm in a minority unfortunately.
  • »28.02.16 - 21:34
    Profile