Skip to content

Host

The NSHostingView-backed leaf that mounts one SwiftUI component tree inside QuickGUI.

#Import

Import MacSwiftUiHost from quickgui.

use quickgui::*;

#Usage

let mut host = MacSwiftUiHost::new(|_id| {})?;
host.sync(&[SwiftUiButton::new(1).label("Continue").into()])?;
native_view(host.view())

#API reference

Expand an entry for its description and complete signature. A dash means no declaration default is documented.

MacSwiftUiHost

View source
pub fn new(action: impl Fn(u64) + 'static) -> Result<Self, String>
new_with_eventspub fn new_with_events( action: impl Fn(u64) + 'static, presentation: impl Fn(u64, bool) + 'static, ) -> Result<Self, String>—

Configures new with events for this part.

pub fn new_with_events( action: impl Fn(u64) + 'static, presentation: impl Fn(u64, bool) + 'static, ) -> Result<Self, String>
View source
new_with_control_eventspub fn new_with_control_events( action: impl Fn(u64) + 'static, presentation: impl Fn(u64, bool) + 'static, value: impl Fn(u64, &str) + 'static, submit: impl Fn(u64) + 'static, ) -> Result<Self, String>—

Construct a host that also reports controlled value changes and text-field submissions.

pub fn new_with_control_events( action: impl Fn(u64) + 'static, presentation: impl Fn(u64, bool) + 'static, value: impl Fn(u64, &str) + 'static, submit: impl Fn(u64) + 'static, ) -> Result<Self, String>
View source
viewpub fn view(&self) -> &objc2_app_kit::NSView—

Configures view for this part.

pub fn view(&self) -> &objc2_app_kit::NSView
View source
syncpub fn sync(&mut self, elements: &[SwiftUiElement]) -> Result<bool, String>—

Synchronize the complete ordered SwiftUI descriptor tree. Returns whether the native root view or one of its embedded QuickGUI surfaces changed.

pub fn sync(&mut self, elements: &[SwiftUiElement]) -> Result<bool, String>
View source
sync_buttonspub fn sync_buttons(&mut self, buttons: &[SwiftUiButton]) -> Result<bool, String>—

Compatibility convenience for the original button-only bridge.

pub fn sync_buttons(&mut self, buttons: &[SwiftUiButton]) -> Result<bool, String>
View source
fitting_sizepub fn fitting_size(&self) -> Result<Size, String>—

Current fitting size of the hosted SwiftUI controls at their native size. The headroom the host keeps around content whose effects draw past its bounds, such as Liquid Glass, is excluded; [`Self::effect_inset`] reports it, and placing the view with [`crate::native_view_with_outset`] keeps it outside layout.

pub fn fitting_size(&self) -> Result<Size, String>
View source
effect_insetpub fn effect_inset(&self) -> Result<f32, String>—

Padding the host keeps on each side of its content for effects that draw past a control's bounds; zero unless the content contains such a control.

pub fn effect_inset(&self) -> Result<f32, String>
View source

native_view

View source
pub fn native_view(view: &NSView) -> Element

Embed an AppKit view as a declarative leaf on macOS. QuickGUI synchronizes layout, clipping, visibility, and sibling order while AppKit keeps ownership of the view's rendering and input behavior.