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?

Answer :

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:

More information on gre.env():




Please sign in to leave a comment.

Didn't find what you were looking for?

New post