# NativeControlHost

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/struct-nativecontrolhost/

**struct** · [`ferroui-controls`](/docs/0.5.0/api/ferroui-controls/) · v0.5.0

```rust
struct NativeControlHost
```

Hosts a native control of the platform inside the visual tree: the
native control is created for the top-level the host is attached to and
follows the bounds and the visibility of the host.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L24)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`create_native_control_core`](#function-create_native_control_core)
- [`destroy_native_control_core`](#function-destroy_native_control_core)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`native_control_handle`](#function-native_control_handle)
- [`native_control_handle_changed`](#function-native_control_handle_changed)
- [`try_update_native_control_position`](#function-try_update_native_control_position)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L40)

<a id="function-to_ref"></a>

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<NativeControlHost>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L40)

<a id="function-create_native_control_core"></a>

### create_native_control_core

```rust
fn create_native_control_core(self: &Self, parent: Rc<dyn IPlatformHandle>) -> Rc<dyn IPlatformHandle>
```

Creates the native control as a child of `parent`. The default
asks the native control host of the platform for its default
child.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L40)

<a id="function-destroy_native_control_core"></a>

### destroy_native_control_core

```rust
fn destroy_native_control_core(self: &Self, control: Rc<dyn IPlatformHandle>)
```

Destroys the native control. The default destroys a handle that
can be destroyed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L40)

<a id="function-construct"></a>

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `ferroui_base::FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L139)

<a id="function-new"></a>

### new

```rust
fn new() -> Ref<Self>
```

Creates a native control host.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L155)

<a id="function-native_control_handle"></a>

### native_control_handle

```rust
fn native_control_handle(self: &Self) -> Option<Rc<dyn IPlatformHandle>>
```

The handle of the native control, once it has been created
(internal upstream).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L161)

<a id="function-native_control_handle_changed"></a>

### native_control_handle_changed

```rust
fn native_control_handle_changed(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
```

Raised when the handle of the native control changes (internal
upstream).

Dropping the returned guard removes the handler; `Subscription::detach` keeps it for the
life of the host.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L182)

<a id="function-try_update_native_control_position"></a>

### try_update_native_control_position

```rust
fn try_update_native_control_position(self: &Self) -> bool
```

Moves the native control to the bounds of the host, or hides it
when the host is not visible. Returns `false` when there is no
native control host or the host has no size yet.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/native_control_host.rs#L365)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- [`NativeControlHostImplExt`](/docs/0.5.0/api/ferroui-controls/trait-nativecontrolhostimplext/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- [`InputElementImplExt`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimplext/)
- [`InteractiveImplExt`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimplext/)
- [`LayoutableImplExt`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`StyledElementImplExt`](/docs/0.5.0/api/ferroui-base/trait-styledelementimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- [`VisualImplExt`](/docs/0.5.0/api/ferroui-base/trait-visualimplext/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<NativeControlHost>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`NativeControlHostImpl`](/docs/0.5.0/api/ferroui-controls/trait-nativecontrolhostimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
