MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / setControlValue

Function setControlValue

packages/nativescript-inspector/src/index.ts:2403–2423  ·  view source on GitHub ↗
(target: any, value: unknown)

Source from the content-addressed store, hash-verified

2401}
2402
2403function setControlValue(target: any, value: unknown): void {
2404 if (isKindOf(target, "UISwitch")) {
2405 target.setOnAnimated(Boolean(value), true);
2406 sendActions(target, controlEventValueChanged);
2407 return;
2408 }
2409 if (isKindOf(target, "UISlider")) {
2410 target.value = numberValue(value);
2411 sendActions(target, controlEventValueChanged);
2412 return;
2413 }
2414 if (isKindOf(target, "UISegmentedControl")) {
2415 target.selectedSegmentIndex = numberValue(value);
2416 sendActions(target, controlEventValueChanged);
2417 return;
2418 }
2419 throw new InspectorFailure(
2420 -32011,
2421 "setValue is only supported for UISwitch, UISlider, and UISegmentedControl.",
2422 );
2423}
2424
2425function sendActions(target: any, event: number): void {
2426 if (typeof target.sendActionsForControlEvents === "function") {

Callers 1

performMethod · 0.85

Calls 3

isKindOfFunction · 0.85
sendActionsFunction · 0.85
numberValueFunction · 0.85

Tested by

no test coverage detected