Build desktop apps around explicit state, predictable form behavior, full keyboard access, reusable themes, and durable user data. Use Godot's scene system for composition without putting the entire application in one scene script.
Inspect Before Editing
Scale this inspection to the change's risk, and complete the relevant checks before changing scenes, scripts, project settings, or persisted formats.
- Locate
project.godotand confirm the root. Readconfig/features, main scene, window size and mode, minimum-size handling, stretch/content scale, DPI settings, locale, input actions, and GUI theme configuration. - Run the project's established Godot executable with
--versionwhen available. Match code, resources, and platform APIs to that exact Godot 4.x release. - Inspect representative
.tscn,.gd, and.tresfiles. Record feature boundaries, scene ownership, unique-name use, signal conventions, typed GDScript style, autoloads, services, navigation, dialogs, and naming. - Inspect every existing data path and format:
ConfigFile,FileAccess, JSON, customResource, databases,user://, user-selected files, schema versions, migrations, autosave, and error handling. - Inspect themes, fonts and fallbacks, icon strategy, light/dark/system preference, UI scale, focus styles, shortcuts, menu actions, localization, and right-to-left support.
- Run the current application. Resize to the smallest and largest supported sizes; complete primary workflows with keyboard only; test invalid forms; locate the actual user data directory; and note existing warnings.
Never replace a shipped persistence format or change application identity/user-data location without a migration plan.
Architecture
Use the smallest separation that keeps state testable and UI code understandable:
- Application shell: window-level layout, menus, navigation, global dialogs, and feature mounting.
- Feature view: a scene for one workflow or screen, composed from standard controls and reusable components.
- Feature coordinator: connects view signals to domain operations, owns transient workflow state, and maps results back to the view.
- Domain model/service: typed rules and operations that do not depend on node paths or visual controls.
- Persistence adapter: reads and writes one versioned format, returning explicit errors or results.
Small apps can keep the feature view and coordinator in one script. Split them when validation, persistence, background work, or reuse makes the boundary valuable. Do not create an autoload for every object; reserve global lifetime for genuinely application-wide services.
Form Workflow
- Define a typed data model and validation rules before wiring controls.
- Give every field a persistent label, expected format, and error location.
- Accept normal intermediate editing states. Validate without rewriting text on every keystroke unless strict filtering is a real requirement.
- Parse and normalize at a clear boundary such as submit, focus exit, or an intentional live-preview update.
- Keep entered values after failure, show an actionable error, focus the first invalid field, and disable submission only when that behavior is understandable.
- Emit a semantic command or call a coordinator after validation. Do not let each field save independently unless the product deliberately autosaves.
Typed Form Example
This view validates a workspace label without coupling validation to persistence. %NameEdit, %NameError, and %SaveButton must be unique named controls in the scene.
extends Control
signal save_requested(workspace_name: String)
@onready var name_edit: LineEdit = %NameEdit
@onready var name_error: Label = %NameError
@onready var save_button: Button = %SaveButton
func _ready() -> void:
name_edit.text_changed.connect(_on_name_changed)
name_edit.text_submitted.connect(_on_name_submitted)
save_button.pressed.connect(_submit)
_refresh_validation()
name_edit.grab_focus()
func _validation_message(raw_name: String) -> String:
var candidate: String = raw_name.strip_edges()
if candidate.is_empty():
return "Enter a workspace name."
if candidate.length() > 48:
return "Use 48 characters or fewer."
return ""
func _on_name_changed(_new_text: String) -> void:
_refresh_validation()
func _on_name_submitted(_submitted_text: String) -> void:
_submit()
func _refresh_validation() -> void:
var message: String = _validation_message(name_edit.text)
name_error.text = message
name_error.visible = not message.is_empty()
save_button.disabled = not message.is_empty()
func _submit() -> void:
var message: String = _validation_message(name_edit.text)
if not message.is_empty():
_refresh_validation()
name_edit.grab_focus()
return
save_requested.emit(name_edit.text.strip_edges())
The coordinator handling save_requested should report save failure back to the view rather than pretending persistence succeeded.
Focus and Keyboard Contract
- Set useful initial focus when a window, view, or dialog opens.
- Make Tab and Shift+Tab follow reading order. Set explicit focus neighbors for non-linear layouts.
- Support Enter/accept for the primary action only when it does not conflict with multiline editing or another focused control.
- Support Escape/cancel at the owning dialog or navigation layer.
- Restore focus to the opener after closing a dialog.
- Use
Shortcutresources, menu accelerators, or the project's command system for application shortcuts. Keep buttons/menu items as discoverable alternatives. - Preserve standard text editing, clipboard, undo/redo, selection, and IME behavior.
- Draw visible focus in every theme and control state.
Themes and Persistence
- Apply shared
Themeresources at the app shell or feature root. Use semantic type variations and define normal, hover, pressed, focus, disabled, selected, read-only, and invalid states as applicable. - Support light, dark, high-contrast, and UI-scale preferences only to the scope the product needs. Verify system-theme APIs against the exact Godot and platform version.
- Keep non-game desktop stretch behavior and high-DPI strategy deliberate. Enforce a sensible minimum window size and allow content to scroll or reflow.
- Store settings in a versioned
ConfigFileunderuser://when INI-like typed key/value data is sufficient. - Use user-selected filesystem paths for documents users expect to manage.
user://is for application-owned data, not a substitute for Save As. - Treat save errors, malformed data, unsupported future versions, and migration failures as normal recoverable cases.
- Never store passwords, tokens, or private keys in plain
ConfigFiledata.
Verification
- Parse/import with the matching editor and run existing tests. Use
<godot> --headless --path <project> --editor --quitwhen supported. - Launch from a clean user-data state, an existing valid state, malformed settings, a read-only or failing destination, and an older supported schema.
- Complete all primary workflows using only keyboard. Test Tab, Shift+Tab, arrows, Enter, Escape, Space, menu accelerators, and application shortcuts.
- Test empty, boundary, malformed, pasted, Unicode, locale-specific, and extremely long field values. Verify caret and IME behavior.
- Resize continuously from minimum to large windows. Test high-DPI/UI scale, long translations, fallback fonts, and light/dark/high-contrast modes in scope.
- Open, cancel, confirm, and reopen every dialog. Verify focus containment and restoration.
- Save, close, relaunch, and compare state. Test interrupted/failed writes and confirm the app does not report success after an error.
- Confirm application-owned data uses the expected user directory and exported builds never attempt to write to
res://. - Test release exports on each desktop OS in scope, including app identity, icons, file dialogs, paths, permissions, shortcuts, and window behavior.
- Report data migrations, user-visible behavior changes, test environments, and anything that remains platform-specific or unverified.
Pitfalls
- Putting UI state, business rules, file I/O, and navigation in one root script until none can be tested independently.
- Using node text as the only source of truth after the form has been submitted or saved.
- Filtering every keypress and breaking paste, caret placement, negative numbers, decimals, Unicode, or IME composition.
- Converting an empty or malformed string before validation.
- Showing an error only by color or in a transient tooltip.
- Hiding focus visuals, trapping focus in a custom control, or requiring a mouse for an essential action.
- Overriding common text-editing shortcuts from a global
_inputhandler. - Hard-coding one window size or using stretch settings intended for games to blur a desktop UI.
- Saving application data to
res://, which is not writable in normal exported projects. - Ignoring
Errorreturn values fromConfigFile,FileAccess, or directory operations. - Overwriting an incompatible future schema with defaults and destroying recoverable user data.
- Committing credentials or placing secrets in plain settings files.