A few questions about gui and vscode (SOLVED)

Hello there!
Sorry, first post with some questions already.

  1. GUI related. I’m using the gui.set_enabled() to disable my container (after pressing the start button) that contains two elements: a button (gooey) and a box (background). Calling the method only removes the first one. I couldn’t find anything related in Defold’s documentation.

  2. and how can I open files from external libraries (like gooey) using vscode? I think the only way to do it is downloading and setting up the libraries manually idk.

Thanks!

1 Like

Can you double check that the node you disable is the root node and that all others are children?

The library dependencies are zip files in the .internal folder. The Defold editor will show them as it is designed to do so, but VSCode obviously doesn’t know about them.

1 Like

yep background it’s definitely a child of container.
eee
script

Oh I see. Thanks!

Can you isolate this problem into a small project so that we can take a look?

1 Like

example.zip (582.4 KB)

GUI copied from my main project. Error persist. I just followed the same steps on a new project and worked. I don’t know what Im missing. I’m sorry if this is some trivial thing =/

Ah, found the problem. The things is that as opposed to the lifecycle functions the callback from the Gooey button press doesn’t start with self. The first value is the button table structure itself:

local function hide(self)
	gui.set_enabled(self.node, false)
end

function on_input(self, action_id, action)
	gooey.button("start/bg", action_id, action, hide)
end

You are treating the first value passed to hide() as the script reference when in fact it is the button data structure (refer to Gooey button docs: https://github.com/britzl/gooey#gooeybuttonnode_id-action_id-action-fn-refresh_fn).

And it just happens that the button data structure has a value called node which references the root node of the button. This is why the call to gui.set_enabled() doesn’t fail and only the button is hidden. Change to this:

function on_input(self, action_id, action)
	gooey.button("start/bg", action_id, action, function(button)
		gui.set_enabled(self.node, false)
	end)
end
2 Likes

Ahh makes sense now. It’s working, thank you! Ill read more carefully the libraries docs from now on (or even debug what Im send thought those methods). Sorry to bother and thanks again!

1 Like