fltk.browser

FLTK Browser Widgets

This module provides list browser widgets for displaying and selecting items from a list:

  • HoldBrowser: Single-selection list browser
  • MultiBrowser: Multiple-selection list browser
  • SelectBrowser: Selection browser variant

    Authors

    Dejan Lekić

    License

    BSD-3-Clause

Types 6

Single-selection list browser widget.

HoldBrowser displays a list of items where only one item can be selected at a time. Selection persists until another item is selected or deselect() is called.

Example:

auto browser = new HoldBrowser(10, 10, 200, 300, "Select one:");
browser.add("Item 1");
browser.add("Item 2");
browser.add("Item 3");
browser.value = 1; // Select first item

Fields
HoldBrowserPtr _browserHandle
Constructors
this(int x, int y, int width, int height, string label = null)Creates a new single-selection browser.
Destructors

Multiple-selection list browser widget.

MultiBrowser displays a list of items where multiple items can be selected simultaneously using Ctrl+click or Shift+click.

Example:

auto browser = new MultiBrowser(10, 10, 200, 300, "Select multiple:");
browser.add("Option A");
browser.add("Option B");
browser.add("Option C");
browser.select(1, true);  // Select first
browser.select(3, true);  // Also select third

Fields
MultiBrowserPtr _browserHandle
Methods
int[] selectedLines() constGets all selected line numbers.
Constructors
this(int x, int y, int width, int height, string label = null)Creates a new multiple-selection browser.
Destructors

Selection browser widget.

SelectBrowser is similar to HoldBrowser but selection only persists while the mouse button is held down.

Example:

auto browser = new SelectBrowser(10, 10, 200, 300);
browser.add("Temporary selection 1");
browser.add("Temporary selection 2");

Fields
SelectBrowserPtr _browserHandle
Constructors
this(int x, int y, int width, int height, string label = null)Creates a new selection browser.
Destructors

File type filter for FileBrowser.

files = 0Show only files
directories = 1Show only directories
both = 2Show both files and directories

File system browser widget.

FileBrowser displays directory contents and allows navigation through the file system. It supports filtering by file pattern.

Example:

auto browser = new FileBrowser(10, 10, 300, 400, "Files:");
browser.filter = "*.d";
browser.load("/home/user/projects");

Fields
FileBrowserPtr _browserHandle
Methods
int load(string directory)Loads a directory into the browser.
string filter() constGets the file filter pattern.
void filter(string pattern)Sets the file filter pattern.
FileType fileType() constGets the file type display mode.
void fileType(FileType type)Sets the file type display mode.
Constructors
this(int x, int y, int width, int height, string label = null)Creates a new file browser.
Destructors

Browser widget with checkboxes for each item.

CheckBrowser displays a scrolling list of text items where each item has a checkbox that can be independently checked or unchecked.

Example:

auto browser = new CheckBrowser(10, 10, 200, 300, "Options:");
browser.add("Option 1");
browser.add("Option 2", true);  // Initially checked
browser.add("Option 3");
if (browser.checked(2)) {
    writeln("Option 2 is checked");
}

Fields
CheckBrowserPtr _browserHandle
Methods
CheckBrowserPtr browserHandle() @safe nothrow @nogcReturns the underlying check browser handle.
int add(string text)Adds an unchecked item to the browser.
int add(string text, bool checked)Adds an item with specified checked state.
int remove(int item)Removes an item from the browser.
void clear()Clears all items from the browser.
int nitems() constGets the number of items.
int nchecked() constGets the number of checked items.
bool checked(int item) constGets the checked state of an item.
void setChecked(int item, bool state)Sets the checked state of an item.
void checkAll()Checks all items.
void checkNone()Unchecks all items.
int value() constGets the currently selected item.
string text(int item) constGets the text of an item.
Constructors
this(int x, int y, int width, int height, string label = null)Creates a new check browser.
Destructors