How to let the app active all the time

mag

Active member
3rd Party Module Dev
3rd Party Tool Dev
Joined
Mar 5, 2018
Messages
258
When my window desktop app loses focus, both rendering and updating come to a halt. This also happen in the HTML build and likely other builds as well.

While this behavior may be acceptable on mobile platforms where typically only one task is displayed at a time, it becomes inconvenient on desktop. Specifically, I want my app, which functions as a clock, to continue rendering even when I'm focused on another application.

Any suggestions on how to address this would be greatly appreciated!

Code:
Import mojo
Class MyApp Extends App
    Field x:Float
    Field y
    Method OnCreate()
        SetUpdateRate 60
        Seed=Millisecs()
        y=Rnd(100)
    End
    Method OnUpdate()
        x=x+0.5
     End
    Method OnRender()
        Cls 128,0,255
        DrawRect 10,10,100,100
        DrawText "Hello World!",x,y
    End
    Method OnSuspend()
        Print "OnSuspend"
    End
    Method OnResume()
        Print "OnResume"
    End
End
Function Main()
    New MyApp   
End
 
Add the preprocessor directive/variable to the code.
#MOJO_AUTO_SUSPEND_ENABLED=False

Cerberus:
Import mojo

#MOJO_AUTO_SUSPEND_ENABLED=False

Class MyApp Extends App
    Field x:Float
    Field y
    Method OnCreate()
        SetUpdateRate 60
        Seed=Millisecs()
        y=Rnd(100)
    End
    Method OnUpdate()
        x=x+0.5
     End
    Method OnRender()
        Cls 128,0,255
        DrawRect 10,10,100,100
        DrawText "Hello World!",x,y
    End
   
    Method OnSuspend()
        Print "OnSuspend"
    End
   
    Method OnResume()
        Print "OnResume"
    End
End
Function Main()
    New MyApp  
End
 
Last edited:
  • Love
Reactions: mag
They are under the App Config Settings. These are the predefined target specific preprocessor variables.

@Phil7: The Programming Language Reference documentation should really be updated to include a link to the App Config Settings documentation in the Preprocessor section.
Some thing like:
Target Specific Directives
Cerberus also has built in target specific directives to control the build configuration and output for each of the supported target.
See App Config Settings.
 
Last edited:
Back
Top Bottom