GuiUpdate

Category: GUI
Since engine version: 7.0 OC

Description

Updates an existing GUI window, that has previously been opened with GuiOpen(). It is possible to update only one certain sub-window by passing child_id and target. The update definition looks similar to the original proplist that defined the GUI window for GuiOpen(). However, this function can not update certain properties such as the ID and the target. When the name of a sub-proplist matches the original name of a GUI window, the window is updated. If no existing window was found, a new window is added. Returns true if a window was found.
Because names starting with an underscore (e.g. _child) are anonymous, they will always lead to a new window being added when used in GuiUpdate.

Syntax

bool GuiUpdate(proplist update, int gui_id, int child_id, object target);

Parameters

update:
The proplist containing the parts of the GUI window definition that need to be updated. The proplist is of the same format as the original menu definition that was used for GuiOpen().
gui_id:
The ID of the gui window that was returned by GuiOpen().
child_id:
Optional. If given, the sub-window of the gui_id window with the matching child_id will be updated. Should be used together with the parameter target.
target:
Optional. Should be used together with child_id. The target of the sub-window that will be updated.

Remark

See the GUI documentation for further explanations.

Examples

var menu =
{
	left_part = 
	{
		Right = "50%",
		BackgroundColor = RGB(255, 0, 0),
		icon =
		{
			Left = "50%-2em", Right="50%+2em", Bottom="4em",
			Symbol = Clonk
		}
	},
	right_part = 
	{
		Left = "50%",
		BackgroundColor = RGB(0, 255, 0),
		Text = "On the left site, you can see a Clonk"
	}
};
var menuID = GuiOpen(menu);

var update = 
{
	left_part =
	{
		icon =
		{
			Symbol = Rock
		}
	},
	right_part = 
	{
		Text = "The Clonk is now a rock. :("
	}
}
GuiUpdate(update, menuID)
Opens a menu window and then updates certain parts of it.
var menu =
{
	BackgroundColor = RGB(200, 100, 100)
};
var menuID = GuiOpen(menu);

var update = 
{
	BackgroundColor = RGB(0, 255, 0)
}
for (var i = 0; i < 5; i += 2)
{
	update.Left  = Format("%dem", i);
	update.Right = Format("%dem", i + 1);
	GuiUpdate({_child = update}, menuID);
}
Opens a menu window and then adds three new children to that window.
See also: GUI Documentation, GuiAction_Call, GuiAction_SetTag, GuiClose, GuiOpen, GuiUpdateTag
Zapper, 2014-10