A Dialog Can Now Be a Native Desktop Window
A Dialog Can Now Be a Native Desktop Window
Last week's native-window release could open an editor, inspector, and tool palette as separate operating-system windows. Then an ordinary Dialog.show() inside the inspector looked for the current Form and appeared on the wrong surface.
What is Codename One?
Codename One is an open-source framework for building native iOS, Android, desktop, and web apps from a single Java or Kotlin codebase. Learn more at codenameone.com.
Bug Fix and New Feature
That bug exposed every component that treated βtop levelβ and βformβ as synonyms. PR #5624 fixes those assumptions and adds something more visible: a Dialog can now become a real modal desktop window. For VoIP, VPN, the AppKit port, OTP, contacts, and the rest of this release, read the weekly overview.
Two Useful Kinds of Dialog
The default remains a lightweight dialog painted inside its owner's layered pane. It matches Codename One styling and works on every port. A desktop application can make ordinary confirmation dialogs native windows while keeping the familiar static API:
Dialog.setDefaultNativeWindowMode(true);
boolean delete = Dialog.show("Confirm deletion", "Delete Quarterly report.pdf?", "Delete", "Cancel");
if (delete) {
deleteDocument();
}
An actual JavaSE desktop capture on macOS. The title bar belongs to a separate operating-system window; the body and actions use the application's Codename One theme.
Customizing Dialog Mode
The defaultNativeWindowModeBool theme constant provides the same application-wide setting without a startup call. For a single custom dialog, call setNativeWindowMode(true) on that instance. The instance setting wins over the static default, which wins over the theme. On a port without native windows, the dialog stays lightweight.
Ownership and Popups
Ownership was the real bug. Dialog, Sheet, ToastBar, ComboBox, FloatingActionButton, InfiniteProgress, tooltips, and HTMLComponent all had paths that asked Display for the current form. That question has one answer, even when the event came from another window. The corrected path starts with the component that caused the action:
Dialog details = new Dialog("Details");
details.setTopLevelHost(inspectorWindow);
details.add(new Label("Selection metadata"));
details.show();
The dimming layer, popup position, focus restoration, repaint region, and input routing now belong to that window. Accessibility state is also maintained per top level, so opening an inspector does not replace the main form's accessible root.
Limits of Native Window Mode
Popups should not become surprise windows. An anchored combo-box popup stays attached to its field. A floating-action submenu stays near its button. Turning either into an independent desktop window would break positioning and keyboard behavior, so the new native mode is limited to dialogs and interaction dialogs. Picker inside a window still uses its lightweight popup. Toolbar remains a Form concept.
Consistency Across Platforms
The same contract on Windows and Mac. The test suite opens the same controls in 400 by 300, 900 by 700, and 1000 by 400 windows. The wide case catches code that still reads the main display width. Modal cases verify that the owner is blocked while other event-dispatch work can continue. This also validates the new AppKit port against the existing Windows implementation.
Desktop Work Without a Desktop Fork
The Window API is settling into the same pattern as this week's call, VPN, and contact work. The common API owns the behavior application code can rely on. Each port handles the native surface it actually has. Unsupported behavior stays visible instead of becoming a silent approximation. That consistency matters for security as well as polish.
Next Steps
A confirmation must block the window that contains the sensitive operation. A popup must not leak input to another surface. Accessibility focus must remain attached to the content the user is operating. These details are small until the wrong window accepts a command. Next, read how Catalyst gave way to a real AppKit application.
Comments
No comments yet. Start the discussion.