How to Check the Current Active Screen from Lua
User Question :
Is there some way in the lua script to know which screen is currently active?
Yes, there are a couple ways to tell which screen is active from Lua. If you are in an action callback function, you can tell on what screen the action took place by checking the mapargs.context_screen data that is passed into the function by the event.
Otherwise, you can tell the current screen at any time using gre.env(), which will return information about the application environment. gre.env("active_screen") will return the currently active screen. Keep in mind that if you find you are having to do this a lot, it may make more sense to update a variable on screenshow actions to store the current screen, instead of constantly making calls for this data.
More information on mapargs: http://resources.cranksoftware.com/cranksoftware/v5.3.0/docs/webhelp/index.html#ch12s01.html
More information on gre.env(): http://resources.cranksoftware.com/cranksoftware/v5.3.0/docs/webhelp/index.html#apas01s57.html
Please sign in to leave a comment.