Skip to content

Misc data structures#

Shared state of ImGui.input_text, passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used.
The callback function should return 0 by default.
Callbacks (follow a flag name and see comments in ImGui::ImGuiInputTextFlags declarations for more details)

  • ImGuiInputTextFlags_CallbackEdit: Callback on buffer edit (note that ImGui.input_text already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
  • ImGuiInputTextFlags_CallbackAlways: Callback on each iteration
  • ImGuiInputTextFlags_CallbackCompletion: Callback on pressing TAB
  • ImGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows
  • ImGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
  • ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow.

struct ImGui::ImGuiInputTextCallbackData
inherits Struct #

Included modules

ImGui::ClassType
#event_flag : ImGuiInputTextFlags#
View source

One ImGuiInputTextFlags_Callback* // Read-only

#flags : ImGuiInputTextFlags#
View source

What user passed to ImGui.input_text // Read-only

#user_data : ::Pointer(Void)#
View source

What user passed to ImGui.input_text // Read-only

Arguments for the different callback events#

  • To modify the text buffer in a callback, prefer using the InsertChars() / DeleteChars() function. InsertChars() will take care of calling the resize callback if necessary.
  • If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so ImGui.input_text can update its internal state.
#event_char : ImWchar#
View source

Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0;

#event_key : ImGuiKey#
View source

Key pressed (Up/Down/TAB) // Read-only // [Completion,History]

#buf : ::Pointer(LibC::Char)#
View source

ImGui.text buffer // Read-write // [Resize] Can replace pointer / [Completion,History,Always] Only write to pointed data, don't replace the actual pointer!

#buf_text_len : Int32#
View source

ImGui.text length (in bytes) // Read-write // [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length()

#buf_size : Int32#
View source

Buffer size (in bytes) = capacity+1 // Read-only // [Resize,Completion,History,Always] Include zero-terminator storage. In C land == ARRAYSIZE(my_char_array), in C++ land: string.capacity()+1

#buf_dirty : Bool#
View source

Set if you modify Buf/BufTextLen! // Write // [Completion,History,Always]

#cursor_pos : Int32#
View source
                                  // Read-write   // [Completion,History,Always]
#selection_start : Int32#
View source
                                  // Read-write   // [Completion,History,Always] == to SelectionEnd when no selection)
#selection_end : Int32#
View source
                                  // Read-write   // [Completion,History,Always]

Helper functions for text manipulation.
Use those function to benefit from the CallbackResize behaviors. Calling those function reset the selection.

Resizing callback data to apply custom constraint. As enabled by ImGui.set_next_window_size_constraints. Callback is called during the next ImGui.begin.
NB: For basic min/max size constraint on each axis you don't need to use the callback! The ImGui.set_next_window_size_constraints parameters are enough.

struct ImGui::ImGuiSizeCallbackData
inherits Struct #

Included modules

ImGui::ClassType
#user_data : ::Pointer(Void)#
View source

Read-only. What user passed to ImGui.set_next_window_size_constraints

#pos : ImVec2#
View source

Read-only. Window position, for reference.

#current_size : ImVec2#
View source

Read-only. Current window size.

#desired_size : ImVec2#
View source

Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.

Data payload for Drag and Drop operations: ImGui.accept_drag_drop_payload, ImGui.get_drag_drop_payload#

struct ImGui::ImGuiPayload
inherits Struct #

Included modules

ImGui::ClassType

Members#

#data : ::Pointer(Void)#
View source

Data (copied and owned by dear imgui)

#data_size : Int32#
View source

Data size

[Internal]#

#source_id : ImGuiID#
View source

Source item id

#source_parent_id : ImGuiID#
View source

Source parent id (if available)

#data_frame_count : Int32#
View source

Data timestamp

#data_type : Slice(LibC::Char)#
View source

Data type tag (short user-supplied string, 32 characters max)

#preview : Bool#
View source

Set when ImGui.accept_drag_drop_payload was called and mouse has been hovering the target item (nb: handle overlapping drag targets)

#delivery : Bool#
View source

Set when ImGui.accept_drag_drop_payload was called and mouse button is released over the target item.

Sorting specification for one column of a table (sizeof == 12 bytes)#

struct ImGui::ImGuiTableColumnSortSpecs
inherits Struct #

Included modules

ImGui::ClassType
#column_user_id : ImGuiID#
View source

User id of the column (if specified by a ImGui.table_setup_column call)

#column_index : Int16#
View source

Index of the column

#sort_order : Int16#
View source

Index within parent ImGui::ImGuiTableSortSpecs (always stored in order starting from 0, tables sorted on a single criteria will always have a 0 here)

#sort_direction : ImGuiSortDirection#
View source

ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending (you can use this or SortSign, whichever is more convenient for your sort function)

Sorting specifications for a table (often handling sort specs for a single column, occasionally more)#

Obtained by calling ImGui.table_get_sort_specs.
When 'SpecsDirty == true' you can sort your data. It will be true with sorting specs have changed since last call, or the first time.
Make sure to set 'SpecsDirty = false' after sorting, else you may wastefully sort your data every frame!

struct ImGui::ImGuiTableSortSpecs
inherits Struct #

Included modules

ImGui::ClassType
#specs : Slice(ImGuiTableColumnSortSpecs)#
View source

Pointer to sort spec array.

#specs_count : Int32#
View source

Sort spec count. Most often 1. May be > 1 when ImGuiTableFlags_SortMulti is enabled. May be == 0 when ImGuiTableFlags_SortTristate is enabled.

#specs_dirty : Bool#
View source

Set to true when specs have changed since last time! Use this to sort again, then clear the flag.