FileSystemRoots
classin packageklyn.gui.windows.filesystem
public class FileSystemRoots extends Container
└ FileSystemRoots

Selects a filesystem root in a themed combo box. Windows exposes logical drives such as C:/; Unix exposes /, rather than listing mount points. Roots come from Path.roots() and are enumerated only during construction and an explicit refresh(). No directory is scanned.

The first available root is initially selected. The internal combo box keeps display labels separate from the typed FolderPath selection. Mouse, keyboard and programmatic changes emit selectionChanged with this component as the event source. Refreshing retains the selected root when available and emits only when the selected root actually changes.

import klyn.gui.events
import klyn.gui.windows.filesystem

roots = FileSystemRoots()
roots.selectionChanged += lambda(e as ActionEvent): print(roots.selectedRoot)
# Add roots to a window layout; call roots.refresh() after drive changes.
Properties
Modifier and Type Member Description
public readonly property rootCount
rootCount as ULong
Number of roots in the current snapshot.
public property selectedIndex
selectedIndex as Long
Selected root index, or -1 when nothing is selected.
public property selectedRoot
selectedRoot as FolderPath
Selected filesystem root, or null when nothing is selected.
Inherited Properties
propertyInherited Properties from Container: autoRelayout, childCount, layout, padding
propertyInherited Properties from Widget: accentColor, acceptFileDrops, backgroundColor, borderColor, bottom, canFocus, cornerRadius, cursor, font, foregroundColor, hasFocus, height, isEnabled, isHovered, isManaged, isPressed, isTabStop, isVisible, layoutParams, margin, maxHeight, maxWidth, minHeight, minWidth, parent, preferredHeight, preferredWidth, resolvedStyleCache, resolvedStyleCacheAppearanceMode, resolvedStyleCacheFont, resolvedStyleCacheRevision, resolvedStyleCacheStateKey, resolvedStyleCacheStyleClass, resolvedStyleCacheZoomRevision, right, size, sizePolicy, styleClass, toolTip, width, window, x, y
Events
Modifier and Type Member Description
public event selectionChanged
selectionChanged as ActionEvent
Emitted once when the selected root changes, including selection clearing.
Inherited Events
eventInherited Events from Widget: filesDropped, focusGained, focusLost, keyPressed, keyReleased, mouseMoved, mousePressed, mouseReleased, mouseWheel, paintRequested, resized
Constructors
Modifier and Type Member Description
public FileSystemRoots
FileSystemRoots(initialRoot as FolderPath = null)
Creates the selector and snapshots the available filesystem roots.
Methods
Modifier and Type Member Description
public override applyThemeMetrics
applyThemeMetrics(fontPixelSize as Int, paddingLeft as Int, paddingTop as Int, paddingRight as Int, paddingBottom as Int) as Void
Sizes the component around its combo box using the active theme's control metrics, margins and container padding.
public clearSelection
clearSelection() as Void
Clears the selection without removing the available roots.
public override preferredSizeIncludesContentZoom
preferredSizeIncludesContentZoom() as Boolean
Preferred dimensions already include the child control's content zoom.
public refresh
refresh() as Void
Enumerates roots again and closes the popup.
public rootAt
rootAt(index as Long) as FolderPath
Returns a root without changing the selection.
public selectRoot
selectRoot(root as FolderPath) as Boolean
Selects an available root using normalized Path equality.
Inherited Methods
methodInherited Methods from Container: add, applyLayout, attachWindow, blur, children, clear, paint, paintOverlay, remove, setBounds, withLayout
methodInherited Methods from Widget: applyThemeMetrics, blur, containsPoint, emitFilesDropped, emitFocusGained, emitFocusLost, emitKeyPressed, emitKeyReleased, emitMouseMoved, emitMousePressed, emitMouseReleased, emitMouseWheel, handleTabKey, notifyPaintRequested, paint, paintClipped, paintForeground, paintOverlay, preferredSizeIncludesContentZoom, repaint, requestFocus, resolvePreferredHeight, resolvePreferredWidth, resolvedFont, setBounds
Inherited Operators
operatorInherited Operators from Container: operator[](index as Int) as Widget, operator[](index as UInt) as Widget