Function: getNativeInterface()
getNativeInterface<
T>(obj,iface):T|null
Defined in: packages/ffi/src/native/object.ts:111
Gets a native object as a specific interface type if it implements that interface.
Uses GLib's type system to check if the object implements the specified interface, and returns a wrapped instance if it does.
Type Parameters
| Type Parameter | Description |
|---|---|
T extends NativeObject | The interface type |
Parameters
| Parameter | Type | Description |
|---|---|---|
obj | NativeObject | The native object to check |
iface | NativeClass<T> | The interface class (must have a glibTypeName property) |
Returns
T | null
The wrapped interface instance, or null if not implemented
Example
const editable = getNativeInterface(widget, Gtk.Editable);
if (editable) {
const text = editable.getText();
}