CombustUI-Mojo Logo

Comprehensive documentation for all public functions, constants, and FFI bindings in CombustUI-Mojo.

Light Dark

Application (Mojo)

addEventListener(id: Int, handler: EventHandler)

Registers an event handler for a widget identified by its id. This function allows you to associate a specific EventHandler instance with a UI widget, ensuring that when an event (like a click, keypress, or mouse movement) occurs on that widget, the appropriate handler logic is executed. The handler will only be triggered if the event type defined within the EventHandler matches the actual event that occurred.

Defined in: mjui/_app.mojo

app.addEventListener(1, handler)

setElementById(id: Int, element: FLTK_WIDGET_POINTER)

Associates a raw FLTK widget pointer (FLTK_WIDGET_POINTER) with a unique integer id. This mapping is crucial for managing UI elements dynamically. By assigning a simple integer ID, you can easily retrieve, update, or manipulate specific widgets throughout your application without needing to hold onto the raw FLTK pointer directly.

Defined in: mjui/_app.mojo

app.setElementById(22, label)

getElementById(id: Int) -> FLTK_WIDGET_POINTER

Retrieves the FLTK_WIDGET_POINTER associated with a given integer id. This function acts as a lookup mechanism, allowing your Mojo code to get a reference to an underlying FLTK widget based on the ID previously set with setElementById. This is fundamental for performing operations on specific UI components.

Defined in: mjui/_app.mojo

var label = app.getElementById(22)

markWindowPTRAsMain(ptr: FLTK_WIDGET_POINTER)

Designates a specific FLTK window pointer (ptr) as the main application window. This is important for the application's lifecycle management. The internal event loop will monitor this designated window for close events, and once it detects that this main window has been closed by the user, the application will gracefully terminate.

Defined in: mjui/_app.mojo

app.markWindowPTRAsMain(window)

attachLoopHook(hook: fn() raises)

Attaches a callable function (hook) to the application's main event loop. This mechanism allows you to inject custom logic that needs to be executed continuously on every iteration of the event loop. This is useful for tasks such as updating game states, performing animations, background processing, or any other operations that require regular execution while the UI is active.

Defined in: mjui/_app.mojo

app.attachLoopHook(my_hook)

execute()

Starts the main FLTK event loop. Calling this function initiates the continuous polling for and processing of UI events. It enters an infinite loop, constantly checking for user interactions (mouse clicks, keypresses, window events), dispatching them to any registered EventHandlers, and executing any attached loop hooks. The application will remain responsive and active until the designated main window is closed or an explicit exit signal is received, at which point the loop terminates.

Defined in: mjui/_app.mojo

app.execute()

EventHandler (Mojo)

set(trigger: Int, handler: Handler)

Sets both the trigger event type (trigger) and the handler function (handler) for this EventHandler. This function provides a convenient way to configure an event handler, specifying precisely which type of event it should respond to and what action it should take when that event occurs.

Defined in: mjui/EventHandler.mojo

handler.set(MJUI_KEYDOWN, my_handler)

attachHandler(handler: Handler)

Sets the handler function (handler) that will be executed when the associated event is triggered. This allows you to define the specific code block or logic that should run in response to an event, separating the event detection from the action to be performed.

Defined in: mjui/EventHandler.mojo

handler.attachHandler(my_handler)

attachTrigger(trigger: Int)

Sets the integer trigger event type that this EventHandler will respond to. By setting the trigger, you define which specific UI event (e.g., a button click, a key press) will cause this event handler to become active and execute its attached function.

Defined in: mjui/EventHandler.mojo

handler.attachTrigger(MJUI_KEYDOWN)

trigger()

Executes the currently attached handler function. This function is typically called internally by the event loop when an event matching the `trigger` is detected for the associated widget. You can also call it manually to programmatically invoke the handler's logic.

Defined in: mjui/EventHandler.mojo

handler.trigger()

Utility Functions (Mojo)

rgb(r: UInt32, g: UInt32, b: UInt32) -> UInt32

Converts individual red, green, and blue color components (each ranging from 0-255) into a single 32-bit unsigned integer. This packed integer format is the standard color representation used by FLTK (Fast Light Toolkit) and is essential when setting widget colors or drawing custom graphics.

Defined in: mjui/utils.mojo

var color = rgb(255, 128, 0)

str_to_int8(str: String) -> List[Int8]

Converts a Mojo String into a List of Int8 (ASCII character codes). This utility is vital for interoperability with C++ FFI (Foreign Function Interface) functions, which often expect string data to be provided as a null-terminated byte array. This function correctly transforms Mojo strings into this compatible format.

Defined in: mjui/utils.mojo

var ascii_codes = str_to_int8("Hello")

readFromStringBytes(bytes: StringBytes) -> String

Converts a StringBytes span (a low-level byte array representation, typically received from C++ FFI functions) back into a human-readable Mojo String. The function intelligently reads the byte array until it encounters a null terminator, ensuring that only the relevant string data is converted.

Defined in: mjui/utils.mojo

var s = readFromStringBytes(bytes)

createIdFrom(id: String) -> Int

Generates a simple integer ID from a given String. This is achieved by summing the ASCII character codes of the input string. While this method provides a quick and convenient way to get a unique identifier for widgets, it is important to note that it is not collision-proof for all possible string inputs and should be used where strict uniqueness guarantees are not paramount.

Defined in: mjui/utils.mojo

var widget_id = createIdFrom("button1")

convertStringToBytes(strn: String) -> StringBytes

Converts a Mojo String into a StringBytes span. This low-level byte representation is specifically designed for efficient and safe passing of string data to C++ FFI functions. It ensures that the string data is correctly formatted for consumption by the underlying C++ libraries.

Defined in: mjui/utils.mojo

var bytes = convertStringToBytes("Label")

Constants (Mojo)

Event Types

Event types used for widget and application event handling.

NameValueDescriptionDefined In
MJUI_NO_EVENT0Represents the absence of an event. This value is used when no specific UI interaction or system event has occurred.mjui/const.mojo
MJUI_PUSH1Indicates a mouse button or a similar input device button has been pressed down. This event is commonly used for clickable widgets like buttons.mjui/const.mojo
MJUI_RELEASE2Signifies that a mouse button or a similar input device button has been released after being pressed. It often follows a MJUI_PUSH event.mjui/const.mojo
MJUI_ENTER3Occurs when the mouse cursor enters the bounding box of a widget. Useful for hover effects or changing widget appearance upon mouse entry.mjui/const.mojo
MJUI_LEAVE4Triggers when the mouse cursor leaves the bounding box of a widget. Typically used to revert changes made during an MJUI_ENTER event.mjui/const.mojo
MJUI_DRAG5Generated when the mouse cursor is moved while a mouse button is held down. Essential for drag-and-drop functionalities or drawing applications.mjui/const.mojo
MJUI_FOCUS6Indicates that a widget has gained input focus, meaning it is ready to receive keyboard input. This happens when a user clicks on an input field or tabs to it.mjui/const.mojo
MJUI_UNFOCUS7Occurs when a widget loses input focus, typically when another widget gains focus or the user clicks outside the widget.mjui/const.mojo
MJUI_KEYDOWN / MJUI_KEYBOARD8Fired when a keyboard key is pressed down. Note: MJUI_KEYDOWN and MJUI_KEYBOARD are aliases for the same event type (value 8).mjui/const.mojo
MJUI_KEYUP9Generated when a keyboard key is released after being pressed. This complements MJUI_KEYDOWN for full key press detection.mjui/const.mojo
MJUI_CLOSE10Signifies that a widget or window is being closed. This is particularly important for window management to perform cleanup operations.mjui/const.mojo
MJUI_MOVE11Indicates that a widget has been moved on the screen, typically by user interaction or programmatic changes to its position.mjui/const.mojo
MJUI_SHORTCUT12Triggered when a keyboard shortcut is activated. This allows for quick access to specific application functionalities.mjui/const.mojo
MJUI_DEACTIVATE13Occurs when a widget becomes inactive or disabled, meaning it can no longer receive input or interact with the user.mjui/const.mojo
MJUI_ACTIVATE14Fired when a widget becomes active or re-enabled, allowing it to receive user input and interactions again.mjui/const.mojo
MJUI_HIDE15Indicates that a widget has been hidden from view. The widget still exists but is not rendered on the screen.mjui/const.mojo
MJUI_SHOW16Occurs when a previously hidden widget becomes visible again.mjui/const.mojo
MJUI_PASTE17Generated when content is pasted into an input field or a widget that supports paste operations.mjui/const.mojo
MJUI_SELECTIONCLEAR18Fired when any current text selection within a widget is cleared.mjui/const.mojo
MJUI_MOUSEWHEEL19Triggered when the mouse scroll wheel is used. This is commonly used for scrolling content within a scrollable area or zooming.mjui/const.mojo
MJUI_DND_ENTER20Indicates that a drag-and-drop operation has entered the bounding box of a widget.mjui/const.mojo
MJUI_DND_DRAG21Occurs when a drag-and-drop operation is actively being dragged over a widget.mjui/const.mojo
MJUI_DND_LEAVE22Fired when a drag-and-drop operation leaves the bounding box of a widget.mjui/const.mojo
MJUI_DND_RELEASE23Triggered when a drag-and-drop operation is released over a widget, signaling a potential drop.mjui/const.mojo
MJUI_SCREEN_CONFIGURATION_CHANGED24Occurs when the screen configuration (e.g., resolution, display settings) changes.mjui/const.mojo
MJUI_FULLSCREEN25Indicates that a window has entered or exited fullscreen mode.mjui/const.mojo
MJUI_ZOOM_GESTURE26Generated by a zoom gesture, typically on touch-enabled devices.mjui/const.mojo
MJUI_ZOOM_EVENT27A generic zoom event, which can be triggered by various input methods.mjui/const.mojo
handler.attachTrigger(MJUI_PUSH)

Cursor Types

Cursor types for widgets and windows.

NameValueDescriptionDefined In
MJUI_CURSOR_DEFAULT0The default cursor, typically an arrow.mjui/const.mojo
MJUI_CURSOR_ARROW35A standard arrow cursor, used for general pointing and clicking.mjui/const.mojo
MJUI_CURSOR_CROSS66A crosshair cursor, often used for drawing or selecting precise points.mjui/const.mojo
MJUI_CURSOR_WAIT76An hourglass or spinning circle cursor, indicating that the application is busy and the user should wait.mjui/const.mojo
MJUI_CURSOR_INSERT77A text insertion cursor (I-beam), used for text input fields.mjui/const.mojo
MJUI_CURSOR_HAND31A hand cursor, typically used to indicate a clickable or draggable element.mjui/const.mojo
MJUI_CURSOR_HELP47A cursor with a question mark, indicating that help is available for the element under the cursor.mjui/const.mojo
MJUI_CURSOR_MOVE27A four-directional arrow cursor, used to indicate that an element can be moved in any direction.mjui/const.mojo
MJUI_CURSOR_NS78A vertical double-headed arrow, used for resizing elements vertically (North-South).mjui/const.mojo
MJUI_CURSOR_WE79A horizontal double-headed arrow, used for resizing elements horizontally (West-East).mjui/const.mojo
MJUI_CURSOR_NWSE80A diagonal double-headed arrow (North-West to South-East), used for diagonal resizing.mjui/const.mojo
MJUI_CURSOR_NESW81A diagonal double-headed arrow (North-East to South-West), used for diagonal resizing.mjui/const.mojo
MJUI_CURSOR_N70An arrow pointing North (up), used for resizing.mjui/const.mojo
MJUI_CURSOR_NE69An arrow pointing North-East (up-right), used for resizing.mjui/const.mojo
MJUI_CURSOR_E49An arrow pointing East (right), used for resizing.mjui/const.mojo
MJUI_CURSOR_SE8An arrow pointing South-East (down-right), used for resizing.mjui/const.mojo
MJUI_CURSOR_S9An arrow pointing South (down), used for resizing.mjui/const.mojo
MJUI_CURSOR_SW7An arrow pointing South-West (down-left), used for resizing.mjui/const.mojo
MJUI_CURSOR_W36An arrow pointing West (left), used for resizing.mjui/const.mojo
MJUI_CURSOR_NW68An arrow pointing North-West (up-left), used for resizing.mjui/const.mojo
MJUI_CURSOR_NONE255An invisible cursor, used when no cursor should be displayed.mjui/const.mojo

Layout Flags

Layout direction and resize flags for flex layouts.

NameValueDescriptionDefined In
MJUI_MJUIEX_HORIZONTAL1Specifies that a flex layout container should arrange its child widgets horizontally, from left to right.mjui/const.mojo
MJUI_MJUIEX_VERTICAL0Specifies that a flex layout container should arrange its child widgets vertically, from top to bottom.mjui/const.mojo
RESIZE_XY100Indicates that a widget or layout should be resizable in both horizontal (X) and vertical (Y) directions.mjui/const.mojo
RESIZE_XONLY110Indicates that a widget or layout should only be resizable in the horizontal (X) direction.mjui/const.mojo
RESIZE_YONLY111Indicates that a widget or layout should only be resizable in the vertical (Y) direction.mjui/const.mojo

Box Types

Box types for widget backgrounds and borders.

NameValueDescriptionDefined In
MJUI_FLAT_BOX1A simple, flat box with no 3D appearance, often used for clean, modern interfaces.mjui/const.mojo
MJUI_UP_BOX2A box type that appears raised or extruding from the surface, creating a 3D button-like effect.mjui/const.mojo
MJUI_DOWN_BOX3A box type that appears sunken or recessed into the surface, often used to indicate a pressed state or an input field.mjui/const.mojo
MJUI_UP_FRAME4A raised frame border, similar to MJUI_UP_BOX but typically without a filled background.mjui/const.mojo
MJUI_DOWN_FRAME5A sunken frame border, similar to MJUI_DOWN_BOX but typically without a filled background.mjui/const.mojo
MJUI_THIN_UP_BOX6A thinner version of MJUI_UP_BOX, providing a subtle raised effect.mjui/const.mojo
MJUI_THIN_DOWN_BOX7A thinner version of MJUI_DOWN_BOX, providing a subtle sunken effect.mjui/const.mojo
MJUI_THIN_UP_FRAME8A thinner version of MJUI_UP_FRAME.mjui/const.mojo
MJUI_THIN_DOWN_FRAME9A thinner version of MJUI_DOWN_FRAME.mjui/const.mojo
MJUI_ENGRAVED_BOX10A box with an engraved appearance, making the content seem carved into the surface.mjui/const.mojo
MJUI_EMBOSSED_BOX11A box with an embossed appearance, making the content seem raised from the surface.mjui/const.mojo
MJUI_ENGRAVED_FRAME12An engraved frame, similar to MJUI_ENGRAVED_BOX but typically without a filled background.mjui/const.mojo
MJUI_EMBOSSED_FRAME13An embossed frame, similar to MJUI_EMBOSSED_BOX but typically without a filled background.mjui/const.mojo
MJUI_BORDER_BOX14A box with a simple border around its perimeter.mjui/const.mojo
MJUI_SHADOW_BOX15A box with a shadow effect, giving it a lifted appearance.mjui/const.mojo
MJUI_BORDER_FRAME16A simple border frame without a filled background.mjui/const.mojo
MJUI_SHADOW_FRAME17A frame with a shadow effect.mjui/const.mojo
MJUI_ROUNDED_BOX18A box with rounded corners, providing a softer aesthetic.mjui/const.mojo
MJUI_RSHADOW_BOX19A rounded box with a shadow effect.mjui/const.mojo
MJUI_ROUNDED_FRAME20A rounded frame without a filled background.mjui/const.mojo
MJUI_RFLAT_BOX21A rounded, flat box.mjui/const.mojo
MJUI_ROUND_UP_BOX22A rounded box with a raised appearance.mjui/const.mojo
MJUI_ROUND_DOWN_BOX23A rounded box with a sunken appearance.mjui/const.mojo
MJUI_DIAMOND_UP_BOX24A diamond-shaped box with a raised appearance.mjui/const.mojo
MJUI_DIAMOND_DOWN_BOX25A diamond-shaped box with a sunken appearance.mjui/const.mojo
MJUI_OVAL_BOX26An oval-shaped box.mjui/const.mojo
MJUI_OSHADOW_BOX27An oval-shaped box with a shadow effect.mjui/const.mojo
MJUI_OVAL_FRAME28An oval-shaped frame.mjui/const.mojo
MJUI_OFLAT_BOX29An oval, flat box.mjui/const.mojo
MJUI_PLASTIC_UP_BOX30A box with a plastic-like raised appearance.mjui/const.mojo
MJUI_PLASTIC_DOWN_BOX31A box with a plastic-like sunken appearance.mjui/const.mojo
MJUI_PLASTIC_UP_FRAME32A plastic-like raised frame.mjui/const.mojo
MJUI_PLASTIC_DOWN_FRAME33A plastic-like sunken frame.mjui/const.mojo
MJUI_PLASTIC_THIN_UP_BOX34A thin plastic-like raised box.mjui/const.mojo
MJUI_PLASTIC_THIN_DOWN_BOX35A thin plastic-like sunken box.mjui/const.mojo
MJUI_PLASTIC_THIN_UP_FRAME36A thin plastic-like raised frame.mjui/const.mojo
MJUI_PLASTIC_THIN_DOWN_FRAME37A thin plastic-like sunken frame.mjui/const.mojo
MJUI_PLASTIC_ROUND_UP_BOX38A rounded plastic-like raised box.mjui/const.mojo
MJUI_PLASTIC_ROUND_DOWN_BOX39A rounded plastic-like sunken box.mjui/const.mojo
MJUI_GTK_UP_BOX40A box style resembling the GTK+ toolkit's raised elements.mjui/const.mojo
MJUI_GTK_DOWN_BOX41A box style resembling the GTK+ toolkit's sunken elements.mjui/const.mojo
MJUI_GTK_UP_FRAME42A GTK+ style raised frame.mjui/const.mojo
MJUI_GTK_DOWN_FRAME43A GTK+ style sunken frame.mjui/const.mojo
MJUI_GTK_THIN_UP_BOX44A thin GTK+ style raised box.mjui/const.mojo
MJUI_GTK_THIN_DOWN_BOX45A thin GTK+ style sunken box.mjui/const.mojo
MJUI_GTK_THIN_UP_FRAME46A thin GTK+ style raised frame.mjui/const.mojo
MJUI_GTK_THIN_DOWN_FRAME47A thin GTK+ style sunken frame.mjui/const.mojo
MJUI_GTK_ROUND_UP_BOX48A rounded GTK+ style raised box.mjui/const.mojo
MJUI_GTK_ROUND_DOWN_BOX49A rounded GTK+ style sunken box.mjui/const.mojo
MJUI_GLEAM_UP_BOX50A box with a gleam-like raised appearance.mjui/const.mojo
MJUI_GLEAM_DOWN_BOX51A box with a gleam-like sunken appearance.mjui/const.mojo
MJUI_GLEAM_UP_FRAME52A gleam-like raised frame.mjui/const.mojo
MJUI_GLEAM_DOWN_FRAME53A gleam-like sunken frame.mjui/const.mojo
MJUI_GLEAM_THIN_UP_BOX54A thin gleam-like raised box.mjui/const.mojo
MJUI_GLEAM_THIN_DOWN_BOX55A thin gleam-like sunken box.mjui/const.mojo
MJUI_GLEAM_ROUND_UP_BOX56A rounded gleam-like raised box.mjui/const.mojo
MJUI_GLEAM_ROUND_DOWN_BOX57A rounded gleam-like sunken box.mjui/const.mojo
MJUI_OXY_UP_BOX58A box with an Oxygen-like (KDE Plasma) raised appearance.mjui/const.mojo
MJUI_OXY_DOWN_BOX59A box with an Oxygen-like (KDE Plasma) sunken appearance.mjui/const.mojo
MJUI_OXY_UP_FRAME60An Oxygen-like raised frame.mjui/const.mojo
MJUI_OXY_DOWN_FRAME61An Oxygen-like sunken frame.mjui/const.mojo
MJUI_OXY_THIN_UP_BOX62A thin Oxygen-like raised box.mjui/const.mojo
MJUI_OXY_THIN_DOWN_BOX63A thin Oxygen-like sunken box.mjui/const.mojo
MJUI_OXY_THIN_UP_FRAME64A thin Oxygen-like raised frame.mjui/const.mojo
MJUI_OXY_THIN_DOWN_FRAME65A thin Oxygen-like sunken frame.mjui/const.mojo
MJUI_OXY_ROUND_UP_BOX66A rounded Oxygen-like raised box.mjui/const.mojo
MJUI_OXY_ROUND_DOWN_BOX67A rounded Oxygen-like sunken box.mjui/const.mojo
MJUI_OXY_BUTTON_UP_BOX68An Oxygen-like raised button box.mjui/const.mojo
MJUI_OXY_BUTTON_DOWN_BOX69An Oxygen-like sunken button box.mjui/const.mojo
MJUI_FREE_BOXTYPE70A free box type, which can be customized.mjui/const.mojo
MJUI_MAX_BOXTYPE255Represents the maximum value for box type constants.mjui/const.mojo

Label Types

Label rendering types for widgets.

NameValueDescriptionDefined In
MJUI_LABEL_TYPE_NORMAL0Standard text rendering.mjui/const.mojo
MJUI_LABEL_TYPE_SHADOW1Renders text with a shadow effect, adding depth.mjui/const.mojo
MJUI_LABEL_TYPE_EMBOSSED2Renders text with an embossed effect, making it appear raised.mjui/const.mojo
MJUI_LABEL_TYPE_MULTI3Enables multi-line text rendering, allowing text to wrap within the widget's bounds.mjui/const.mojo
MJUI_LABEL_TYPE_IMAGE4Specifies that the label should display an image instead of text.mjui/const.mojo

Image Types

Image format constants for loading images.

NameValueDescriptionDefined In
PNG0Specifies the Portable Network Graphics (PNG) image format, known for lossless compression and support for transparency.mjui/const.mojo
JPEG1Specifies the Joint Photographic Experts Group (JPEG) image format, commonly used for photographs due to its lossy compression.mjui/const.mojo
SVG2Specifies the Scalable Vector Graphics (SVG) format, an XML-based vector image format for two-dimensional graphics with support for interactivity and animation.mjui/const.mojo
BMP3Specifies the Bitmap (BMP) image format, a raster graphics image file format used to store bitmap digital images.mjui/const.mojo
GIF4Specifies the Graphics Interchange Format (GIF), known for its support of both static and animated images with a limited color palette.mjui/const.mojo
ANIM_GIF5Specifically denotes an animated GIF image format, allowing for multiple frames to be displayed in sequence.mjui/const.mojo

Alignment

Alignment options for text and widgets.

NameValueDescriptionDefined In
ALIGN_CENTER0Aligns content to the center of the widget's bounding box.mjui/const.mojo
ALIGN_TOP1Aligns content to the top of the widget's bounding box.mjui/const.mojo
ALIGN_BOTTOM2Aligns content to the bottom of the widget's bounding box.mjui/const.mojo
ALIGN_LEFT3Aligns content to the left of the widget's bounding box.mjui/const.mojo
ALIGN_RIGHT4Aligns content to the right of the widget's bounding box.mjui/const.mojo
ALIGN_INSIDE5Aligns content within the widget's interior, respecting padding.mjui/const.mojo
ALIGN_CLIP6Clips content that extends beyond the widget's boundaries.mjui/const.mojo
ALIGN_WRAP7Wraps text content to multiple lines if it exceeds the widget's width.mjui/const.mojo
TEXT_OVER_IMAGE8Displays text content over an image within the same widget.mjui/const.mojo
IMAGE_OVER_TEXT9Displays an image over text content within the same widget.mjui/const.mojo

Visual Schemes

See useScheme

Visual style schemes for the UI.

NameValueDefined In
GTK0mjui/utils.mojo
GLEAM1mjui/utils.mojo
PLASTIC2mjui/utils.mojo
useScheme(GTK)

getEventNameFromNum(num: Int) -> String

Returns the string name corresponding to an integer event type number. This utility function is helpful for debugging and logging event information.

Defined in: mjui/const.mojo

var name = getEventNameFromNum(1)  # "MJUI_PUSH"

FFI Bindings (Mojo/C++)

Widget Management

mjuiGrabEvent() -> int64_t

Retrieves the next event from the event queue. The returned int64_t combines the widget ID and event type. Returns -2 if no event is available.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

var event = mjuiGrabEvent()

mjuiShowWidget(widget)

Makes the given FLTK widget visible.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiShowWidget(my_button)

mjuiHideWidget(widget)

Hides the given FLTK widget.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiHideWidget(my_label)

mjuiRedraw(widget)

Forces the given FLTK widget to redraw itself immediately, updating its appearance on the screen.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiRedraw(my_input)

mjuiSetWidgetColor(widget, color)

Sets the background color of the specified FLTK widget.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiSetWidgetColor(my_button, rgb(255, 0, 0))

mjuiSetWidgetTextColor(widget, color)

Sets the color of the text label for the specified FLTK widget.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiSetWidgetTextColor(my_label, rgb(0, 0, 0))

mjuiSetWidgetSelectionColor(widget, color)

Sets the selection color for the FLTK widget, typically used for highlighting selected text in input fields or selected items in lists.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiSetWidgetSelectionColor(my_input, rgb(0, 128, 255))

mjuiSetWidgetBox(widget, box)

Applies a specific box type (Fl_Boxtype) to the FLTK widget, defining its border and background style.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiSetWidgetBox(my_button, MJUI_FLAT_BOX)

mjuiSetWidgetLabel(widget, label)

Sets the text label for the specified FLTK widget.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiSetWidgetLabel(my_label, convertStringToBytes("New Label"))

BEGIN_WIDGET_APPEND(group)

Marks the beginning of adding child widgets to an FLTK group widget.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

BEGIN_WIDGET_APPEND(my_layout)
// Add widgets here
END_WIDGET_APPEND(my_layout)

END_WIDGET_APPEND(group)

Marks the end of adding child widgets to an FLTK group widget.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

END_WIDGET_APPEND(my_layout)

mjuiGetWidgetHeight(widget)

Returns the current height of the specified FLTK widget in pixels.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

var h = mjuiGetWidgetHeight(my_button)

mjuiGetWidgetWidth(widget)

Returns the current width of the specified FLTK widget in pixels.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

var w = mjuiGetWidgetWidth(my_label)

mjuiWindowSetResizable(window, widget)

Makes a specific widget within an Fl_Window resizable, allowing it to adapt to window resizing.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiWindowSetResizable(my_window, my_layout)

mjuiApplyImage(widget, image)

Applies an Fl_Image to an FLTK widget, typically used for buttons, labels, or custom drawing areas.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

var img = mjuiLoadImg(100, 100, PNG, convertStringToBytes("logo.png"))
mjuiApplyImage(my_label, img)

mjuiImageScale(img, width, height, proportional)

Scales an Fl_Image to the desired width and height. If proportional is 1, the image will be scaled maintaining its aspect ratio.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

mjuiImageScale(img, 200, 200, 1)

Window Management

mjuiCreateWindow(width, height, resize, fullscreen, no_border, title_r)

Creates a new FLTK Fl_Double_Window with specified width, height, and options for resizeability, fullscreen mode, no_border, and a title.

Defined in: mjui/fltk_bindings/libc/Window/MJUIWindow.cc

var window = mjuiCreateWindow(800, 600, 1, 0, 0, convertStringToBytes("My App"))

mjuiWindowTitleSet(window, new_title_r)

Sets the title of the given Fl_Double_Window to new_title_r.

Defined in: mjui/fltk_bindings/libc/Window/MJUIWindow.cc

mjuiWindowTitleSet(window, convertStringToBytes("New Title"))

mjuiWindowVisibilityStatus(window, condition)

Returns the visibility status of the window. condition can be WINDOW_VISIBLE (0) or WINDOW_MINIMIZED (1). Returns 1 if true, 0 if false, -1 if condition is invalid.

Defined in: mjui/fltk_bindings/libc/Window/MJUIWindow.cc

var is_visible = mjuiWindowVisibilityStatus(window, 0)  # 0 = WINDOW_VISIBLE

mjuiWindowPositionSet(window, x, y)

Sets the top-left position of the Fl_Double_Window on the screen to (x, y).

Defined in: mjui/fltk_bindings/libc/Window/MJUIWindow.cc

mjuiWindowPositionSet(window, 100, 100)

Button & Input Widgets

mjuiCreateButton(x, y, w, h, id, label_r)

Creates a new custom FLTK Button widget at (x, y) with specified width, height, id, and a label.

Defined in: mjui/fltk_bindings/libc/Button/MJUIButton.cc

var button = mjuiCreateButton(100, 30, 10, 10, 1, convertStringToBytes("Click Me"))

mjuiCreateCheckButton(x, y, w, h, id, label_r)

Creates a new custom FLTK MJUI_CheckButton widget at (x, y) with specified width, height, id, and a label.

Defined in: mjui/fltk_bindings/libc/Button/MJUIButton.cc

var check = mjuiCreateCheckButton(100, 30, 10, 50, 2, convertStringToBytes("Check Me"))

mjuiCheckButtonGetState(checkButton)

Returns the current state of a MJUI_CheckButton (1 if checked, 0 if unchecked).

Defined in: mjui/fltk_bindings/libc/Button/MJUIButton.cc

var state = mjuiCheckButtonGetState(check)

mjuiCreateInput(x, y, w, h, id, numOnly, label_r)

Creates a single-line Input field. numOnly (1 for numeric only, 0 for any text) and label (placeholder) are configurable.

Defined in: mjui/fltk_bindings/libc/Input/MJUIInput.cc

var input = mjuiCreateInput(10, 90, 200, 30, 3, 0, convertStringToBytes("Enter text..."))

mjuiCreateChoice(x, y, w, h)

Creates a select dropdown. Options can be added using mjuiAddOptionToChoice

Defined in: mjui/fltk_bindings/libc/Input/MJUIInput.cc

var input = mjuiCreateInput(10, 90, 200, 30, 3, 0, convertStringToBytes("Enter text..."))

mjuiCreateMultilineInput(x, y, w, h, id, label_r)

Creates a multiline MultiLineInput field with a placeholder label.

Defined in: mjui/fltk_bindings/libc/Input/MJUIInput.cc

var multi = mjuiCreateMultilineInput(10, 130, 200, 60, 4, convertStringToBytes("Multiline..."))

mjuiSetInputValue(input, value)

Sets the current value (text) of an FLTK Fl_Input widget.

Defined in: mjui/fltk_bindings/libc/Input/MJUIInput.cc

mjuiSetInputValue(input, convertStringToBytes("Hello"))

mjuiGrabInput(input) -> StringBytes

Gets the current value (text) of an FLTK Fl_Input widget.

Defined in: mjui/fltk_bindings/libc/Input/MJUIInput.cc

var bytes = mjuiGrabInput(input)
var str = readFromStringBytes(bytes) # This is necessary since grab input returns bytes

mjuiGrabChoice(input) -> Int

Gets the current index (text) of the selected option in FLTK Fl_Choice widget.

Defined in: mjui/fltk_bindings/libc/Input/MJUIInput.cc

var bytes = mjuiGrabChoice(input)
var str = readFromStringBytes(bytes) # This is necessary since grab input returns bytes

Label & Image Widgets

mjuiCreateLabel(x, y, width, height, id, text)

Creates a new custom FLTK MJUILabel widget at (x, y) with specified width, height, id, and text.

Defined in: mjui/fltk_bindings/libc/Label/MJUILabel.cc

var label = mjuiCreateLabel(10, 10, 200, 30, 5, convertStringToBytes("Hello World"))

mjuiSetTextProperties(label, size, color, type)

Sets the font size, color, and type (MJUI_LABEL_TYPE_NORMAL, etc.) of the text for an MJUILabel.

Defined in: mjui/fltk_bindings/libc/Label/MJUILabel.cc

mjuiSetTextProperties(label, 14, rgb(0, 0, 0), MJUI_LABEL_TYPE_NORMAL)

mjuiTextAlign(label, alignment)

Sets the text alignment within an MJUILabel.

Defined in: mjui/fltk_bindings/libc/Label/MJUILabel.cc

mjuiTextAlign(label, ALIGN_CENTER)

mjuiLoadImg(width, height, imgType, path)

Loads an image from the specified path with desired width, height, and imgType (e.g., PNG, JPEG, SVG, GIF, ANIM_GIF). Returns an Fl_Image pointer.

Defined in: mjui/fltk_bindings/libc/Label/MJUILabel.cc

var img = mjuiLoadImg(100, 100, PNG, convertStringToBytes("logo.png"))

Layouts & Containers

mjuiCreateLayoutFlex(x, y, w, h, dir)

Creates a new FLTK MJUI_Flex layout container at (x, y) with specified width, height, and layout direction (MJUI_MJUIEX_HORIZONTAL or MJUI_MJUIEX_VERTICAL).

Defined in: mjui/fltk_bindings/libc/Layout/MJUILayouts.cc

var layout = mjuiCreateLayoutFlex(0, 0, 800, 600, MJUI_MJUIEX_VERTICAL)

mjuiSetFlexResize(l, r)

Sets the resize direction for a MJUI_Flex layout. r is RESIZE_XY, RESIZE_XONLY, or RESIZE_YONLY.

Defined in: mjui/fltk_bindings/libc/Layout/MJUILayouts.cc

mjuiSetFlexResize(layout, RESIZE_XY)

mjuiSetFlexMarginGapSettings(l, margin, gap)

Sets the margin (spacing around the layout) and gap (spacing between child widgets) for a MJUI_Flex layout. Pass -1 for either to keep current value.

Defined in: mjui/fltk_bindings/libc/Layout/MJUILayouts.cc

mjuiSetFlexMarginGapSettings(layout, 10, 5)

mjuiSetFlex(l, w, span)

Sets the flex span for a specific widget within a MJUI_Flex layout. The span determines how much space the widget occupies relative to other flex items.

Defined in: mjui/fltk_bindings/libc/Layout/MJUILayouts.cc

mjuiSetFlex(layout, my_button, 2)

mjuiSetMarginExplicit(l, left, top, right, bottom)

Sets explicit left, top, right, and bottom margins for a MJUI_Flex layout.

Defined in: mjui/fltk_bindings/libc/Layout/MJUILayouts.cc

mjuiSetMarginExplicit(layout, 5, 5, 5, 5)

mjuiFlexCalculateLayout(l)

Forces the MJUI_Flex layout to recalculate and apply its child widget positions and sizes based on its current properties.

Defined in: mjui/fltk_bindings/libc/Layout/MJUILayouts.cc

mjuiFlexCalculateLayout(layout)

mjuiScrollContainer(x, y, w, h)

Creates a new Fl_Scroll container widget at (x, y) with specified width and height, enabling scrollability for its children.

Defined in: mjui/fltk_bindings/libc/Layout/Containers.cc

var scroll = mjuiScrollContainer(0, 0, 400, 300)

mjuiScrollSetBarBGColor(s, c, sbar)

Sets the background color of the scroll bar for an Fl_Scroll container. sbar selects which scroll bar: 0 for vertical, 1 for horizontal, 2 for both.

Defined in: mjui/fltk_bindings/libc/Layout/Containers.cc

mjuiScrollSetBarBGColor(scroll, rgb(220, 220, 220), 0)

mjuiScrollSetBarFGColor(s, c, sbar)

Sets the foreground color of the scroll bar for an Fl_Scroll container. sbar selects which scroll bar: 0 for vertical, 1 for horizontal, 2 for both.

Defined in: mjui/fltk_bindings/libc/Layout/Containers.cc

mjuiScrollSetBarFGColor(scroll, rgb(100, 100, 100), 0)

mjuiScrollBy(s, x, y)

Scrolls the Fl_Scroll container by x pixels horizontally and y pixels vertically from its current position.

Defined in: mjui/fltk_bindings/libc/Layout/Containers.cc

mjuiScrollBy(scroll, 0, 50)  # Scrolls down by 50 pixels

Event Loop & Utility

mjuiGrabEvent() -> int64_t

Retrieves the next event from the event queue. The returned int64_t combines the widget ID and event type. Returns -2 if no event is available.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

var event = mjuiGrabEvent()

fl_check() -> Int

Processes any pending FLTK events and returns 1 if there are still events to process, 0 otherwise. Used to keep the UI responsive without blocking.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

while fl_check():
    # Do background work

fl_ready() -> Int

Checks if there are any FLTK events ready to be processed. Returns 1 if events are ready, 0 otherwise.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

if fl_ready() == 1:
    fl_check()

mjuiEventKey() -> Int

Returns the integer key code of the most recent keyboard event. Useful for custom key handling in event-driven code.

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

var key = mjuiEventKey()

useScheme(scheme: Int)

Sets the global FLTK visual scheme. scheme can be GTK (0), GLEAM (1), or PLASTIC (2).

Defined in: mjui/fltk_bindings/libc/BaseWidgetHelpers.cc

useScheme(GTK)
useScheme(GLEAM)
useScheme(PLASTIC)