Function Reference

Descriptions and usage examples of Nuklear functions. This reference is meant to be a complementary resource to the Nuklear Usage Guide.

nk_begin, nk_begin_titled

boolean nk_begin(NkContext context, CharSequence name, NkRect rect, int options)
boolean nk_begin_titled(NkContext context, CharSequence name, CharSequence title, NkRect rect, int options)

Creates a window. Widget code beyond this point will draw the widgets inside the window.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
CharSequence name
A string used to identify the window, it must be unique among all windows. For nk_begin(), this is shown in the window's header.
CharSequence title
This is displayed in the header of the window.
NkRect rect
An object of type NkRect that defines the position and size of the window.
int options
A set of flags that define the appearance and behaviour of the window, use a bitwise OR to combine them. The following list describes the ones I found that had a visible effect:
  • NK_WINDOW_TITLE - If this is not present, the window will not have a title bar.
  • NK_WINDOW_BORDER - Shows a border around the window. See the window styling section for information about styling.
  • NK_WINDOW_NO_SCROLLBAR - Prevents the window from ever displaying a scroll bar even when the content exceeds the height or width of the window.
  • NK_WINDOW_MINIMIZABLE - The title bar has a minimize button. When minimized, the all of the content is invisible except for the title bar.
  • NK_WINDOW_SCALABLE - Allows the resizing of the window by clicking and dragging on the bottom right corner of the window.
  • NK_WINDOW_MOVABLE - Allows the user to click on the title bar and drag to move the window.
  • NK_WINDOW_CLOSABLE - The title bar has a close button. Clicking this does not close the window, instead it just sets the window's internal state as closed for one frame. Use nk_window_is_closed() to choose whether or not to render the window.

nk_edit_focus

boolean nk_edit_focus(NkContext context, int options)

Gives focus to the next text field widget.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
int options
Options to be applied to the widget that is being focused, I think. If I am correct, it will use the same values as nk_edit_string():
  • NK_EDIT_FIELD - Make an ordinary text field
  • NK_EDIT_MULTILINE - Displays a text area that allows line breaks instead of a single-line text field
  • NK_EDIT_NO_CURSOR - The user cannot move the text cursor to the middle of the string
  • NK_EDIT_SELECTABLE - The user is able to select a portion of the text
  • NK_EDIT_GOTO_END_ON_ACTIVATE - Starts the cursor at the end of the string when the user focuses the field.

nk_edit_string

int nk_edit_string(NkContext context, int options, ByteBuffer content, IntBuffer length, int maxLength, NkPluginFilterI filter)

Creates a text field.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
int options
Options for the text field. It can take one or more of the following constants:
  • NK_EDIT_FIELD - Make an ordinary text field
  • NK_EDIT_MULTILINE - Displays a text area that allows line breaks instead of a single-line text field
  • NK_EDIT_NO_CURSOR - The user cannot move the text cursor to the middle of the string
  • NK_EDIT_SELECTABLE - The user is able to select a portion of the text
  • NK_EDIT_GOTO_END_ON_ACTIVATE - Starts the cursor at the end of the string when the user focuses the field.
ByteBuffer content
This is a reserved section of memory in which the function writes the text that the user typed.
IntBuffer length
Indicates the number of bytes in the ByteBuffer contain actual data.
int maxLength
Indicates the maximum number of characters that the user is allowed to type into the field.
NkPluginFilterI filter
A reference to a function to be used as a filter. I'm not certain what arguments it has to take or what return value it should have, but there are some defaults that can be used which are shown below.
  • Nuklear::nnk_filter_ascii - Non-ASCII characters are ignored
  • Nuklear::nnk_filter_binary - I'm not sure about this one, sorry
  • Nuklear::nnk_filter_decimal - Restricted to digits 0 to 9
  • Nuklear::nnk_filter_default - I'm not sure about this one either, it doesn't seem to do anything.
  • Nuklear::nnk_filter_float - Restricted to digits 0-9, ., - and +. Possibly "e" and "E" as well.
  • Nuklear::nnk_filter_hex - Restricted to 0-9 and A-F
  • Nuklear::nnk_filter_oct - Restricted to 0-7
Null is a valid value for this argument.

The return value is an integer with any number of the following constants:

  • NK_EDIT_ACTIVE - The text field is currently focused
  • NK_EDIT_INACTIVE - The text field is not focused
  • NK_EDIT_ACTIVATED - The text field has just received focus
  • NK_EDIT_DEACTIVATED - The text field has just lost focus
  • NK_EDIT_COMMITED - The user pressed Enter to submit the text in the field

nk_end

void nk_end(NkContext context)

Ends the window context. Widget code beyond this point will not be inside the window.

NkContext context
A reference to the context object we initialized when setting up Nuklear.

nk_group_begin, nk_group_begin_titled

boolean nk_group_begin(NkContext context, CharSequence name, CharSequence title, int options)
boolean nk_group_begin_titled(NkContext context, CharSequence name, CharSequence title, int windowOptions)

Begins a group. For more details see the section about groups.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
CharSequence name
A unique identifier for the group. For nk_group_begin() calls, this may also be used in the title bar of the group.
CharSequence title
Shown in the title bar of the group, if a title bar is present.
int options
A set of flags that define the appearance and behaviour of the group. It uses a the same flags as the window. Use a bitwise OR to combine them. The following list describes window options and how they affect groups:
  • NK_WINDOW_TITLE - If this is not present, the group will not have a title bar.
  • NK_WINDOW_BORDER - Shows a border around the group. See the group styling section for information about styling.
  • NK_WINDOW_NO_SCROLLBAR - Prevents the group from ever displaying a scroll bar even when the content exceeds the height or width of the group.
  • NK_WINDOW_MINIMIZABLE - Adds a minimize button to the title bar. It seems to be only for windows and not groups, because clicking the minimize button caused the program to crash.
  • NK_WINDOW_SCALABLE - Seems to have no effect on groups.
  • NK_WINDOW_MOVABLE - Does not work well on groups. Attempts to drag the group around result in the group quickly snapping back into place.
  • NK_WINDOW_CLOSABLE - Adds a close button to the title bar. This probably works the same as with the window, but I could not verify it. See Making a Closable Window for details.

Returns true of the content inside the group should be rendered, false otherwise. See Groups for details.

nk_group_end

void nk_group_end(NkContext context)

Ends a group. For more details see the section about groups.

NkContext context
A reference to the context object we initialized when setting up Nuklear.

nk_label

void nk_label(NkContext context, ByteBuffer text, int alignment)

Displays text.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
ByteBuffer text
The text that we want to display in the label.
int alignment
Indicates how the text should be aligned inside the space reserved for it
  • NK_TEXT_ALIGN_LEFT - Left aligned
  • NK_TEXT_ALIGN_RIGHT - Right aligned
  • NK_TEXT_ALIGN_CENTERED - Horizontally centered
  • NK_TEXT_ALIGN_TOP - Aligned to the top of the row
  • NK_TEXT_ALIGN_BOTTOM - Aligned to the bottom of the row
  • NK_TEXT_ALIGN_MIDDLE - Vertically centered

nk_layout_row_begin

void nk_layout_row_begin(NkContext context, int type, float height, int itemsPerRow)

Begins rendering a row of the requested type and specifies its size and the number of elements contained within it. All code that follows this function call will be inside the row until nk_layout_row_end() is called.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
int type
Pass in the constant NK_STATIC for a static row and NK_DYNAMIC for a dynamic row.
float height
The height of the row in pixels.
int itemsPerRow
The number of widgets that fit horizontally on one line.

nk_layout_row_dynamic

void nk_layout_row_dynamic(NkContext context, float height, int itemsPerRow)

Begins rendering a dynamic row and specifies its size and the number of elements contained within it. The row ends when a new row function is called or if its parent group or window ends.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
float height
The height of the row in pixels.
int itemsPerRow
The number of widgets that fit horizontally on one line.

nk_layout_row_end

void nk_layout_row_end(NkContext context)

Ends the row that was started by the most recent nk_layout_row_begin() call.

NkContext context
A reference to the context object we initialized when setting up Nuklear.

nk_layout_row_push

void nk_layout_row_push(NkContext context, float width)

Reserves space of the specified width in the current row for the next widget. The height of this reserved space was determined by the function that started the row.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
float width
The width of the space to be reserved.

nk_layout_row_static

void nk_layout_row_static(NkContext context, float height, float width, int itemsPerRow)

Begins rendering a dynamic row and specifies its size and the number of elements contained within it. The row ends when a new row function is called or if its parent group or window ends.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
float height
The height of the row in pixels.
float width
The width of widgets contained in this row in pixels.
int itemsPerRow
The number of widgets that fit horizontally on one line.

nk_property_double

void nk_property_double(NkContext context, String label, double min, double[] value, double max, double step, float incPerPixel)

Creates a number field that allows the user to select a double.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
String label
The name of the field. This is shown next to the number. In order to allow for multiple fields with the same label, you can prefix the label with "#".
double min
The minimum permitted value for the field.
double[] value
An array of size 1 in which the value is read and written.
double max
The maximum permitted value for the field.
double step
The amount that the value is changed when an arrow is clicked.
float incPerPixel
The amount that the value is changed per pixel of movement when the mouse is being dragged along the widget. Even though the field has double precision, the value change per pixel is still measured using a floating point number.

nk_property_float

void nk_property_float(NkContext context, String label, float min, float[] value, float max, float step, float incPerPixel)

Creates a number field that allows the user to select an float.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
String label
The name of the field. This is shown next to the number. In order to allow for multiple fields with the same label, you can prefix the label with "#".
float min
The minimum permitted value for the field.
float[] value
An array of size 1 in which the value is read and written.
float max
The maximum permitted value for the field.
float step
The amount that the value is changed when an arrow is clicked.
float incPerPixel
The amount that the value is changed per pixel of movement when the mouse is being dragged along the widget.

nk_property_int

void nk_property_int(NkContext context, String label, int min, int[] value, int max, int step, float incPerPixel)

Creates a number field that allows the user to select an integer.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
String label
The name of the field. This is shown next to the number. In order to allow for multiple fields with the same label, you can prefix the label with "#".
int min
The minimum permitted value for the field.
int[] value
An array of size 1 in which the value is read and written.
int max
The maximum permitted value for the field.
int step
The amount that the value is changed when an arrow is clicked.
float incPerPixel
The amount that the value is changed per pixel of movement when the mouse is being dragged along the widget. Even though the property is an integer, this value can be a floating point number so that the integer only changes after dragging the cursor across multiple pixels.

nk_slider_int

int nk_slider_int(NkContext context, int min, IntBuffer currentValue, int max, int step)

Creates a slider. Documentation for the slider widget will be available in the future.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
int min
The value that the slider has when the knob is all the way to the left.
IntBuffer currentValue
The buffer to which this function writes the value that was given by the user. This is also used for initializing the slider with a specified value.
int max
The value that the slider has when the knob is all the way to the right.
int step
The amount by which the slider's value increments for each unit it moves towards the right.

I am not sure what the return value is, I will need to do more research. It might return some flags or perhaps the current value of the slider.

nk_style_from_table

void nk_style_from_table(NkContext context, NkColor.Buffer colors)

Sets the colors of all elements and widgets in one function call. See Creating a Theme for details.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
NkColor.Buffer colors
This is equivalent to an array of NkColor structs. The index in the array indicates which property to change and the element at that index is the color to be used on the specified property.

nk_style_push_color

void nk_style_push_color(NkContext context, NkColor property, NkColor value)

Adds the specified value to the top of the stack for the specified style property.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
NkColor property
A pointer to the NkColor struct that the stack belongs to. This struct will take the value of whichever element that is at the top of the stack at any given moment.
NkColor value
The value to be added to the stack.

nk_style_push_font

void nk_style_push_font(NkContext context, NkFont font)

Adds the specified font to the global font stack. Whichever font is at the top of the stack at any given moment will be used when drawing elements and widgets.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
NkFont font
A struct containing all of the data necessary to render text. Fonts are complicated to handle, but there is one block of code showing how to set one up in the Setup section.

nk_style_push_style_item

void nk_style_push_style_item(NkContext context, NkStyleItem property, NkStyleItem value)

Adds the specified value to the top of the stack for the specified style property.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
NkStyleItem property
A pointer to the NkStyleItem struct that the stack belongs to. This struct will take the value of whichever element that is at the top of the stack at any given moment.
NkStyleItem value
The value to be added to the stack.

nk_style_push_vec2

void nk_style_push_vec2(NkContext context, NkVec2 property, NkVec2 value)

Adds the specified value to the top of the stack for the specified style property.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
NkVec2 property
A pointer to the NkVec2 struct that the stack belongs to. This struct will take the value of whichever element that is at the top of the stack at any given moment.
NkVec2 value
The value to be added to the stack.

nk_widget_has_mouse_click_down

boolean nk_widget_has_mouse_click_down(NkContext context, int button, boolean down)

Indicates whether a mouse button is currently pressed within the boundaries of the next widget.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
int button
One of the constants indicating which mouse button to test for. Can take one of the following values:
  • NK_BUTTON_LEFT - Test the left mouse button
  • NK_BUTTON_MIDDLE - Test the middle mouse button (usually triggered by clicking the scroll wheel on a modern mouse)
  • NK_BUTTON_RIGHT - Test the right mouse button
boolean down
Indicates the expected return value for when the mouse is down within the boundaries of the next widget. When set to true, the function returns true when the mouse is pressed and false otherwise. When set to false, the function returns false when the mouse is pressed and true otherwise.

nk_widget_is_mouse_clicked

boolean nk_widget_is_mouse_clicked(NkContext context, int button)

Indicates whether a mouse button has been released within the boundaries of the next widget.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
int button
One of the constants indicating which mouse button to test for. Can take one of the following values:
  • NK_BUTTON_LEFT - Test the left mouse button
  • NK_BUTTON_MIDDLE - Test the middle mouse button (usually triggered by clicking the scroll wheel on a modern mouse)
  • NK_BUTTON_RIGHT - Test the right mouse button

nk_window_is_closed

boolean nk_window_is_closed(NkContext context, CharSequence name)

Tests if a window is closed.

NkContext context
A reference to the context object we initialized when setting up Nuklear.
CharSequence name
The name of the window that is being tested.

Returns true if the window should be closed, false otherwise.