Thread Tools Display Modes
09/21/14, 12:10 AM   #1
Sternentau
board director
 
Sternentau's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 17
Detecting system menu is open

Servus all,

what do you think would be the best way to detect that the player has opened the system menu (by pressing ESC) to hide the addon's windows?

Sternentau
  Reply With Quote
09/21/14, 04:56 AM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Sternentau View Post
Servus all,

what do you think would be the best way to detect that the player has opened the system menu (by pressing ESC) to hide the addon's windows?

Sternentau
How to detect state change of game menu scene:
Lua Code:
  1. GAME_MENU_SCENE:RegisterCallback("StateChange", function(oldState, newState)
  2.         if newState == SCENE_SHOWING then
  3.             d("Scene manager has started showing game menu scene.")
  4.         elseif newState == SCENE_SHOWN then
  5.             d("Game menu scene is fully shown.")
  6.         elseif newState == SCENE_HIDING then
  7.             d("Scene manager has started hiding game menu scene.")
  8.         elseif newState == SCENE_HIDDEN then
  9.             d("Game menu scene is completely hidden.")
  10.         end
  11.     end)

But I'd use a bit different approach. Create a scene fragment from your top level window and then add it to scenes where you want to show it.
http://www.esoui.com/portal.php?&id=27&pageid=12
  Reply With Quote
09/22/14, 12:32 PM   #3
Fyrakin
 
Fyrakin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 129
I use
Lua Code:
  1. ZO_GameMenu_InGame:IsHidden()
to know when Menu is open.
  Reply With Quote
09/22/14, 12:37 PM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Fyrakin View Post
I use
Lua Code:
  1. ZO_GameMenu_InGame:IsHidden()
to know when Menu is open.
If you just want to know if the game menu scene is active, you can also use:
Lua Code:
  1. GAME_MENU_SCENE:IsShowing()

If you use this function or callback mentioned above depends on how you want to use it.

Callback is automatically fired every time when scene state is changed, so it is probably easier method how to show or hide your window:
lua Code:
  1. GAME_MENU_SCENE:RegisterCallback("StateChange", function(oldState, newState)
  2.         if newState == SCENE_SHOWING then
  3.             yourWindow:SetHidden(true)
  4.         elseif newState == SCENE_HIDDEN then
  5.             yourWindow:SetHidden(false)
  6.         end
  7.     end)

But if you already have function which shows/hides window eg. some kind of OnUpdate handler, you might want to use function posted by Fyrakin.

Last edited by Garkin : 09/22/14 at 12:50 PM.
  Reply With Quote
09/22/14, 11:04 PM   #5
Sternentau
board director
 
Sternentau's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 17
Thank you a lot Fyrakin and Garkin!
Now i have the idea - great
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Detecting system menu is open


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off