GUI: treat fragment as overlay and lose focus onClose
Hey I've been following this tutorial https://wiki.esoui.com/SimpleNotebookTutorial/part6 and prepared the following code:
Lua Code:
The ToogleBox() function is bound to a key and can be closed via a $(parent)BtnClose Button inside the box or via a keybind. Currently when I toggle the box, everything from the UI will hide except my box and my mouse. Pressing the key or closing the box via the BtnClose button will hide my mouse and get my UI back. Goal: Toggle the box so that the box is acting like a overlay to my current base UI. (without a mouse icon) By enabling the "mouse icon drag mode" (I don't know the name of this mode :D) I should be able to close the box via the button or the keybind. After closing it, the mouse should disappear and my base UI should be brought to the top again. I hope this is kind of understandable. :D Thanks in advance. :) |
Do NOT put the fragment creation code into your toggle function or you will create a new fragment each time you press the keybind.
Just remove this from the function and put it below local sm = SCENE_MANAGER local fragment = ZO_SimpleSceneFragment:New(window) local scene = ZO_Scene:New(UAN.name, SM) scene:AddFragment(fragment) This will only create the fragment once. Not sure why you need to define a new scene on your own. local scene = ZO_Scene:New(UAN.name, SM) Isn't it enough to use the existing HUD or HUD_UI scene? Here is an example for a TOPLEVELCONTROL (your boxwindow control) added to a fragment which automatically hides with the UI (if inventory is shown e.g.) or shows with the UI (if inv., is closed e.g) https://wiki.esoui.com/Scene_Manager:_On_scene_change If you want to show the box control or hide it manually without the fragment taking care of it, you need to use SetHidden(true/false) on your toplevelcontrol as the toggle function is called. But it will also added (in my example above) to the fragment of the hud_Scene and thus be shown/hidden with the HUD_SCENE through the base game. |
Thank you for your reply. :)
This is not what I really wanted but I solved it now with the following code: Lua Code:
My problem was that the scene "hudui" would stay active when I closed the box via a button. When I close the box I expect to go back to the "hud" scene that's why I need to toggle the "hudui" scene to the "hud" scene. Ingame you can observe the current scene with this command: Lua Code:
|
Oh thanks for ZO_SceneManager_ToggleHUDUIBinding(), did forget about this one :)
|
There is still one edge case where I want to close my window and another UI from another addon is active at the same time which will just close because of the toggle.
Need to figure out how I can get the number of all active fragments? in a scene and if there are more than two, just close only my own window. I don't even know what type my GUI is, which is defined in my XML file. It must be a kind of control or fragment. :confused: |
If you know the other addon's name add it to your addon's manifest txt file in the tag ##OptionalDependsOn: OtherAddonFolderName
It will asure that your addon is loaded AFTER the other addon has loaded and that you are able to access the other addons global variables properly. You can also wait for event_player_activated to be fired as it will be the same in the end (all addons have loaded by this time) then (but it fires several times, at each reloadui e.g. and maybe zone changes). Do you know the other addon? If not you need to find it out by using e.g. /ZGOO mouse in teh chat (uisng the addon ZGOO) on the control you'd like to inspect. Or just disable the other addons and enable them 1 afer another again. Or use a tool like Notepadd++ and the "search in files" of the tool to find addons in your AddOns directory which use the keyword scene_manager or fragment or something like the stuff you are searching for. To get the active fragments check SCENE_MANAGER.currentScene.fragments. It should be a table containing all fragments active at the time you check it. |
It's not exactly a specific addon or has something to do with overlapping. But imagine you toogle a addon which brings up the hudui mode and the addon's GUI.
Now when I open my addon and toggle it off again the ZO_SceneManager_ToggleHUDUIBinding() will be executed and closes both addons because it toggles the whole hudui. My current state is that maybe I have to look it up in the global table (_G) and detect other addons. They are basically children controls like my addon but there are over 400 other controls. :mad: |
You maybe shouldn't use the hud toggle function then and only close your addon, or let the user decided with a settings menu (LibAddonMenu) maybe if the whole scene should be closed or only your addon top level control:SetHidden(true).
There is only on and off. If the use decides to close the scene everything is closed which is attached (including all fragments + their contmrols). This is standard and correct. |
Yeah so after I hit the CloseBtn just the addon closes and the scene hudui will remain.
The idea originally came from AlphaGear where exactly this is possible but I cannot reproduce it. :( The command in the addon was "SM:ToggleTopLevel(AG_Panel)" but it did nothing on my side and it wasn't a function written inside the addon so I thought it has to come from the ZOS API. I also have a TopLevelControl over everything just to clarify. |
Quote:
|
Quote:
EDIT: Found out that of course I had to register the window first: SM:RegisterTopLevel(window,false) |
All times are GMT -6. The time now is 09:07 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI