Yureka LogoDocs

Notepad

Notepad is a multi-tab text editor built into OSSIM. It serves as a prime example of an app handling complex state, dirty-flag tracking, and tight integration with OS-level file dialogs.

Core Features

  • Multi-Tab Interface: Edit multiple documents concurrently (NewTab, CloseTab, SwitchToTab).
  • Undo/Redo Stack: Maintains history for each document (Undo, Redo).
  • State Tracking: Tracks if a document is "dirty" (has unsaved changes) and prompts the user accordingly before closing.
  • View Options: Word wrap toggle and font scaling (SetZoom).

Architecture & Dependencies

The UNotepadApp class acts as the controller managing an array of FNotepadDocument structs.

  • FNotepadDocument: A struct holding the FilePath, text Content, bIsDirty flag, and the UndoStack/RedoStack.
  • Virtual Filesystem (UVirtualFilesystemSubsystem): Used to physically read and write document content to the user's VFS blob (OpenFile, SaveFile).
  • File Dialogs: Notepad extensively uses UAppBase::OpenFileDialog and UAppBase::SaveFileDialog. The controller handles the OnFileDialogResult(bool bSuccess, const FString& SelectedPath) callback to load or save documents appropriately after the user interacts with the system-wide File Explorer dialog.

Technical Details

  • Controller Class: UNotepadApp (Inherits from UAppBase)
  • View Target: User must assign a UMG Widget to NotepadWidgetClass.
  • Window Specs:
    • Initial Size: 600x400
    • Resizable: true
    • Maximizable: true
  • Key Methods:
    • SaveAll(): Iterates through tabs and saves those marked dirty.
    • MarkDirty() / MarkClean(): Explicit state flags.
  • Delegates Exposed to UI:
    • FNotepadTabsChanged: Fires when a tab is opened or closed.
    • FNotepadActiveTabChanged: Fires when the user switches tabs.

UI Implementation Note

The UMG Widget (NotepadWidgetClass) is responsible for binding to the OnTabsChanged and OnActiveTabChanged events to rebuild its visual tab bar and swap out the multiline editable text box content efficiently.