NuiSpacer

From NWN Lexicon
Jump to navigationJump to search
Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.

A special widget that just takes up layout space.


// A special widget that just takes up layout space.
// If you add multiple spacers to a span, they will try to size equally.
//  e.g.: [ <spacer> <button|w=50> <spacer> ] will try to center the button.
json                     // Element
NuiSpacer();


Return

json Element

Parameters

Description

A special widget that just takes up layout space.


Remarks

Version

This function was added in 1.85.8193.31 of NWN:EE.


Example

NuiSpacers are useful, for spacing. They are a "blank" element that helps control the flow of your layout.


For example, say you have 3 buttons:

json jButtonUpdate	 = NuiId(NuiButton(JsonString("Save")), "buttonSave");
json jButtonDefaults = NuiId(NuiButton(JsonString("Reset Defaults")), "buttonDefaults");
json jButtonCancel = NuiId(NuiButton(JsonString("cancel")), "buttonCancel");

jRow = JsonArray();
jRow = JsonArrayInsert(jRow, jButtonUpdate);
jRow  = JsonArrayInsert(jRow, jButtonDefaults);
jRow  = JsonArrayInsert(jRow, jButtonCancel);
jRow  = NuiRow(jRow);
jRoot = JsonArrayInsert(jRoot, jRow);


You can see they are all cramped together, but adding spacers between them gives a better look :

json jButtonUpdate	 = NuiId(NuiButton(JsonString("Save")), "buttonSave");
json jButtonDefaults = NuiId(NuiButton(JsonString("Reset Defaults")), "buttonDefaults");
json jButtonCancel	 = NuiId(NuiButton(JsonString("cancel")), "buttonCancel");

jRow = JsonArray();
jRow = JsonArrayInsert(jRow, jButtonUpdate);
jRow = JsonArrayInsert(jRow, NuiSpacer());
jRow  = JsonArrayInsert(jRow, jButtonDefaults);
jRow  = JsonArrayInsert(jRow, NuiSpacer());
jRow  = JsonArrayInsert(jRow, jButtonCancel);
jRow  = NuiRow(jRow);
jRoot = JsonArrayInsert(jRoot, jRow);


Another useful trick, is you can use NuiWidth and NuiHeight :

// same example above, but with NuiWidth around NuiSpacer
jRow = JsonArrayInsert(jRow, NuiWidth(NuiSpacer(), 128.0f));

See Also

functions:

NUI Functions, NuiWidth, NuiHeight