# g\_imgui

```lua
function myButtonCallback()
	g_logger.log_info("Callback called")
end

function myToggleCallback(value)
	myBool = value
end

function myD3DHook()
	if g_gui.is_open() then
		g_imgui.set_next_window_size(vec2(400, 600))
		if  g_imgui.begin_window("Test Window", ImGuiWindowFlags_NoResize) then
			g_imgui.begin_child("Test Child", vec2(), true)
			g_imgui.add_button("Test Button", vec2(), myButtonCallback)
			g_imgui.add_checkbox("Test Checkbox", myToggleCallback)
			
			if g_imgui.add_button("Test Button 2", vec2(), function() g_logger.log_info("Callback in scripting thread") end) then
                		g_logger.log_info("Pressed")
            		end 	
			
			g_imgui.end_child()
			g_imgui.end_window()	
		end
	end

	if myBool then
		g_imgui.add_circle_filled(g_imgui.get_display_size() / 2, 50.0, 105, 205, 255)
		g_imgui.add_line(vec2(), g_imgui.get_display_size(), 45, 155, 255)
	end
end

g_lua.register();

id = g_hooking.register_D3D_hook(myD3DHook);

while g_isRunning do
	g_util.yield(100)
end

g_hooking.unregister_hook(id);
g_lua.unregister();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cherax.vip/lua-documentation/api-reference/g_imgui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
