From OpenTTD
Jump to: navigation, search
HAL (Hardware Abstraction Layer)


Window System

Using the Window System
Colour codes that exist in OpenTTD
Adding a text box
Understanding the widget focus system


Add a setting
Add a squirrel function
Do a savegame BUMP

The Map / Scenario

Understanding the Dynamic Landscape Array
Understanding the SaveGame Handler
HOWTO - Create good Scenarios
HOWTO - Add New Town Name Generators

The actual simulation

Using Orders
Train Acceleration

Language and Strings

Format of langfiles
Using OpenTTD Strings
List of Special Strings


The Core Interface

Starting a Server
Connecting to a Server
Using the list of LAN/Internet Games

The OpenTTD TCP Protocol
The OpenTTD UDP Protocol
HOWTO - Debug desyncs

Ingame Console

The Console Window
Using Console Scripting
HOWTO - Add Functions/Commands to the Console
HOWTO - Add Variables to the Console
HOWTO - Direct Variable Access using ICONSOLE_VAR_POINTER
OpenTTD Console Commands
OpenTTD Console Variables
Development History

The way users interact with edit boxes is influenced by the widget focus system. This page describes what modifications that are necessary to add a text box to a window that do not have it yet.

Checklist for adding a text box to a window

  • Add a constant for the widget index eg. OP_WIDGET_NUM_PIZZAS_EDIT (OP = Order Pizza window). Follow the naming pattern of the other widgets in the same window.
  • Add an edit box to the nested widget array:

(should be on one line, but has been broken up on two lines here on the wiki to avoid horizontal scrolling)

  • Add a QueryString member variable to the window class, and initialise it in the constructor with the maximum desired text length.
QueryString filter_editbox; ///< Filter editbox;
  • In your constructor (after FinishInitNested resp. InitNested) link the editbox with the QueryString:
/* Initialize the text edit widget */
this->querystrings[WID_SIL_FILTER_TEXT] = &this->filter_editbox;
  • If needed, assign special behaviour to ENTER/ESC keys, resp OK/CANCEL buttons in the OSK window. For filter editboxes it is expected that ESC clears the editbox:
this->filter_editbox.ok_button = WID_SIL_FILTER_ENTER_BTN;
this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
  • Via the QueryString you can set some other properties, like restricting the accepted character set to digits etc.
  • If you want to focus the edit box by default when the window opens, call the SetFocusedWidget function:
  • If you want editing the editbox trigger some functionality, override the window member function:
virtual void OnEditboxChanged(int widget)

Related articles

Understanding the widget focus system

Personal tools