Add Interactive Elements Like Buttons and Input Fields
Placing Interactive Components
Code Defined Gui Mod makes it straightforward to add clickable buttons, text input fields, and other interactive elements to your custom screens without drawing them as images.
Building Interactivity
1. Define button positions, sizes, and labels in your screen code
2. Attach click handlers that execute actions when players interact with buttons
3. Add text input fields by specifying their location and character limits
4. Create toggle buttons or checkboxes using state variables
5. Link UI actions to mod functionality (open containers, apply filters, modify settings)
Buttons automatically render using the mod's built-in textures and can be tinted to match your design. Text fields support standard keyboard input. The Attribute Filter example shows how to wire buttons to filtering logic, while the List Filter demonstrates slot-based selection. Keep interactive elements clearly separated from decorative ones so players understand what's clickable. Test all interactions thoroughly to ensure buttons respond correctly and input fields accept the expected data types.