Window
classin packageklyn.gui.windows
public abstract class Window extends Widget
└ Window

Base class for graphical windows.

size, width, height and placement dimensions describe the complete visible window, including its title bar and borders. clientSize describes the usable area inside that frame, before menu bars and content margins. There is no implicit content padding. Native frame metrics become definitive when the operating system has created and decorated the window.

A window is centered on its screen by default the first time it is shown. setPlacement() can restore explicit screen bounds and maximized mode. Call centerIn() explicitly when you need to recenter it after changing its requested size before display.

win = MainWindow("Demo")
win.size = (900, 600)
win.show()  # centered by default
Properties
Modifier and Type Member Description
public property appearanceMode
appearanceMode as String
Appearance mode: system, light or dark.
public readonly property clientHeight
clientHeight as Int
Height available inside the window frame, before menu bars or margins.
public readonly property clientSize
clientSize as Tuple<Int, Int>
Read-only dimensions inside the frame as (width, height).
public readonly property clientWidth
clientWidth as Int
Width available inside the window frame, before menu bars or margins.
public readonly property focusedWidget
focusedWidget as Widget = null
Current keyboard target, or null when no widget owns keyboard focus.
public property frame
frame as WindowFrame
Window frame mode.
public property icon
icon as Icon
Application icon displayed by the window manager and native title bar.
public override property isVisible
isVisible as Boolean
Native window visibility, without an explicit foreground activation request.
public property title
title as String
Window title.
Inherited Properties
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 closed
closed as CloseEvent
Event emitted when the native window is closed.
Inherited Events
eventInherited Events from Widget: filesDropped, focusGained, focusLost, keyPressed, keyReleased, mouseMoved, mousePressed, mouseReleased, mouseWheel, paintRequested, resized
Constructors
Modifier and Type Member Description
public Window
Window(kmlFile as String, title as String = "")
No summary.
public Window
Window(title as String = "")
No summary.
Methods
Modifier and Type Member Description
public adjustContentZoom
adjustContentZoom(steps as Int) as Boolean
Adjusts the runtime content zoom for all GUI windows.
public adjustFontZoom
adjustFontZoom(steps as Int) as Boolean
Backward-compatible alias for adjustContentZoom.
public applyContentZoom
applyContentZoom() as Void
Applies the current runtime content zoom without reloading the KSS tree.
public applyLayout
applyLayout() as Void
Synchronizes window bounds with the requested size.
public native applyNativeFrame
applyNativeFrame() as Void
Applies the current frame value to the native window if it already exists.
public applyTheme
applyTheme(mode as String = null) as Void
Applies a new appearance mode to this window and requests a repaint.
public capture
capture(path as Path) as Void throws IOException
Captures the current window client area into a BMP image.
public native capture
capture(filename as String) as Void throws IOException
Captures the current window client area into a BMP image.
public native centerIn
centerIn(container as Container = null) as Void
Centers the window on its screen.
public native close
close() as Void
Closes the window.
public native copyToClipboard
copyToClipboard(text as String) as Boolean
Copies plain text to the operating-system clipboard.
public emitClosed
emitClosed() as Void
Native backend hook that emits the close notification.
public getPlacement
getPlacement() as WindowPlacement
Reads normal screen bounds and the normal/maximized display mode.
public maximize
maximize() as Void
Maximizes while keeping the normal bounds and frame.
public native readFromClipboard
readFromClipboard() as String
Reads plain text from the operating-system clipboard.
public relayout
relayout() as Void
Replays the window layout using the current bounds.
public render
render(painter as Painter) as Void
Native-facing rendering hook.
public override native repaint
repaint() as Void
Repaints the native window client area without forcing a relayout.
public native repaintWidget
repaintWidget(widget as Widget) as Void
Repaints a single widget when the backend can safely do it.
public resetContentZoom
resetContentZoom() as Boolean
Resets the runtime content zoom and native window size.
public resetFontZoom
resetFontZoom() as Boolean
Backward-compatible alias for resetContentZoom.
public restore
restore() as Void
Returns to normal mode, retaining restoration dimensions and position.
public native run
run() as Int
Shows the window and starts its native event loop until it is closed.
public override setBounds
setBounds(x as Int, y as Int, width as Int, height as Int) as Void
Updates the logical bounds and, when created, the complete native size.
public native setPlacement
setPlacement(placement as WindowPlacement) as Void
Restores geometry and mode without changing the selected frame.
public native show
show() as Void
Shows the window and asks the operating system to place it in the foreground with keyboard focus.
public native simulateFilesDropped
simulateFilesDropped(paths as ArrayList<String>, x as Int, y as Int) as Void
Simulates a file drop using native target routing, including modal overlays.
public simulateMouseClick
simulateMouseClick(x as Int, y as Int, button as Int = 1, alt as Boolean = false, control as Boolean = false, shift as Boolean = false) as Void
Simulates a full native mouse click.
public native simulateMousePressed
simulateMousePressed(x as Int, y as Int, button as Int = 1, alt as Boolean = false, control as Boolean = false, shift as Boolean = false) as Void
Simulates a native mouse press routed through the window hit-testing pipeline.
public native simulateMouseReleased
simulateMouseReleased(x as Int, y as Int, button as Int = 1, alt as Boolean = false, control as Boolean = false, shift as Boolean = false) as Void
Simulates a native mouse release routed through the window hit-testing pipeline.
public native syncContentZoomSize
syncContentZoomSize(zoom as Double, reset as Boolean = false) as Void
Synchronizes the native client size with the current content zoom.
public theme
theme() as KssTheme
Returns the active KSS theme for this window.
Inherited Methods
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