SirMallard / Iris

Iris is an Immediate-Mode GUI Library for Roblox for creating debug and visualisation UI and tools, based on Dear ImGui,
https://sirmallard.github.io/Iris/
MIT License
164 stars 25 forks source link

Making 2 different windows from the same line causes issues. #75

Closed SuperCater closed 1 month ago

SuperCater commented 1 month ago

If you make 2 windows from the same line that you then close the connection on, itll kill any windows created on that line after the one closed.

Example:

--// Module
local MyModule = {};

MyModule.Load = function()
    local con; con = Iris:Connect(function()
        if Iris.Window({"My Window"}).closed() then
            con() --// This closes the connection once the window is closed
        end
        Iris.End()
    end)
end

return MyModule
--// Some local script
local MyModule = require(MyModule);

MyModule.Load();

task.wait(10); --// Just for example reasons

MyModule.Load()

If you make an example with this code, if you close the first window, it also closes the second window (i assume because it thinks its a child of the original window). I've also seen it add widgets from the first window to the second window which is even bigger of an issue.

Example of this behavior:

https://github.com/user-attachments/assets/a89783a3-8d78-43cb-a619-122b25dcedef

Ive also made a demo place so you can try this out for yourself (google drive since github doesnt support rbxl files) Code is all in StarterPlayerScripts

https://drive.google.com/file/d/1bPDNmuA1ty1q-O7kQVVGcDNO_tnweLYx/view?usp=sharing

If this issue could be fixed it would be greatly appreciated. Also great job on the library its amazing.

SirMallard commented 1 month ago

Thanks for the report, I'll look into it.

SirMallard commented 1 month ago

I've been looking into this and I think I've found the cause, but it's not something that can be easily fixed.

Is this something you can work around?

SuperCater commented 1 month ago

I've been looking into this and I think I've found the cause, but it's not something that can be easily fixed.

Is this something you can work around?

I could try to, what would you suggest as a work around? My current solution is having a table with all functions and a single Iris:Connect() and just not running the code if the window is closed which seems to work

SirMallard commented 1 month ago

I'm curious what you are using Iris for. Normally a different script would call Iris:Connect and therefore you wouldn't have this problem? Or alternatively, the 'isOpened' state would be connected to a root window which would be used to show or hide every other window.

SuperCater commented 1 month ago

Didn't consider calling connect outside of the module. That seems to fix the issue i was facing. Main reason the way i have it running like this is cause I have implemented to work in an existing UI loader framework like this that uses modules for each UI. I appreciate the help with this.