Expand description
AppKit (macOS) backend for mitsuami.
- Containers are flipped
NSViews that do no layout of their own; the core positions every child withsetFrame:. - Leaf widgets are stock AppKit controls, measured through their cells.
- Lists are view-based
NSTableViews whose cells are the core’s row hosts. - Escape hatches:
tweakfor raw settings of built-in controls,NativeRenderfor custom widgets,NativeViewfor anyNSView, and a rasterizer for drawn custom widgets. - Control actions and delegate callbacks become
UiEvents. rundrives the app: a run-loop observer callsUi::tickbefore the loop sleeps, in all common modes (so live resize relayouts).
Re-exports§
pub use objc2;pub use objc2_app_kit;pub use objc2_foundation;
Structs§
- AppKit
Backend - AppKit
Cx - What a native render or native view gets while its view is created.
- AppKit
Handle - Shared access to an
AppKitBackendafter it was moved into aUi. - AppKit
Services - Backend
Options - How the backend behaves; apps and tests want different things.
- Emitter
- Sends events from native callbacks to the widget’s handlers. Cheap to clone; keep one in closures that outlive creation.
- Native
View - Any
NSViewin the shared tree. It takes part in layout like other leaves; the core seesWidgetKind::Native. - Number
Field - A text field with an
NSStepperbeside it, kept in step: the stepper holds the number, its range and its increment, and the field shows the number and commits what’s typed into it when editing ends. Tweaks get this view: reach the parts withfieldandstepper.
Traits§
- Native
Render - A custom widget’s AppKit render: one per widget, next to its shared
definition (e.g.
rating/macos.rs). Hand it to the widget’sRenderimpl withnative. - Tweakable
- A built-in widget, and the AppKit control that shows it.
Functions§
- ad_hoc
- The renderer for a widget AppKit has no control for, built ad hoc from AppKit views the way Mac apps build it. Not labelled native.
- fatal_
error - Tells the user the app can’t run, in an app-modal critical
NSAlert(runModal, which runs its own loop: there may be no window to put a sheet on), and returns once they dismiss it. The app comes to the front for it, as a launch that fails would otherwise show nothing. Off the main thread there’s nothing AppKit can show, and it returns at once. - init_
for_ tests - Prepares AppKit for tests: no Dock icon, no menu bar takeover.
- native
- The renderer for a widget whose AppKit render is AppKit’s own control.
- run
- Starts the app:
setupcreates the windows, then AppKit’s run loop takes over. Returns when the last window closes. - run_
with run, with options. Launch Services keeps a bundled app to one process already; for a single-instance app, a process it didn’t start (run from a terminal, or outside a bundle) hands its launch to the running one over a Unix socket and returns.- tweak
- Raw settings for a built-in widget’s AppKit control:
appkit::tweak(|b: &NSButton| b.setControlSize(NSControlSize::Large)). SeeTweak. - tweak_
with - Raw settings made from a value, applied again whenever it changes:
appkit::tweak_with(tint, |b: &NSButton, tint| ..).