Skip to content

API Reference / @gtkx/runtime / setProperty

Function: setProperty()

Call Signature

setProperty<TObject, TPropertyMap, TName>(obj, propertyName, jsValue): void

Defined in: packages/runtime/dist/object.d.ts:77

Writes a JavaScript value to a GObject property, converting it to native form using the descriptor. The descriptor converts what it is given rather than checking it against the property's GObject.ParamSpec, so null and undefined written to a numeric or enum property land 0, and a fractional number written to a whole-number property is truncated toward zero, where the same writes to a property installed through registerClass are refused with a TypeError.

Type Parameters

TObject

TObject extends object

TPropertyMap

TPropertyMap extends object = TObject extends object ? TResolver extends () => TMap ? Extract<NonNullable<TMap>, object> : TObject["__writableProperties__"] : TObject["__writableProperties__"]

TName

TName extends string = Extract<NoInfer<keyof TPropertyMap>, string>

Parameters

obj

TObject

The object to write to.

propertyName

TName

The property name.

jsValue

NoInfer<TPropertyMap>[TName]

The value to set.

Returns

void

Call Signature

setProperty(obj, propertyName, descriptor, jsValue): void

Defined in: packages/runtime/dist/object.d.ts:82

Writes a JavaScript value to a GObject property, converting it to native form using the descriptor. The descriptor converts what it is given rather than checking it against the property's GObject.ParamSpec, so null and undefined written to a numeric or enum property land 0, and a fractional number written to a whole-number property is truncated toward zero, where the same writes to a property installed through registerClass are refused with a TypeError.

Parameters

obj

object

The object to write to.

propertyName

string

The property name.

descriptor

Descriptor

Describes the property's type.

jsValue

unknown

The value to set.

Returns

void

Released under the MPL-2.0 License.