Skip to content

@jsvision/ui / okButton

Function: okButton()

okButton(): Button

Defined in: ui/src/dialog/buttons.ts:33

An OK button — the dialog default; emits Commands.ok when activated.

Returns

Button

A Button labelled OK.

Example

ts
import { Dialog, okButton, cancelButton, createEventLoop } from '@jsvision/ui';
import { resolveCapabilities } from '@jsvision/core';

const caps = resolveCapabilities({ env: {}, platform: 'linux' }).profile;
const dialog = new Dialog({ title: ' Confirm ', width: 30, height: 8 });
const ok = okButton();
ok.layout = { position: 'absolute', rect: { x: 6, y: 4, width: 10, height: 2 } };
dialog.add(ok);
dialog.add(cancelButton());

const loop = createEventLoop({ width: 40, height: 12 }, { caps });
loop.mount(dialog);
const command = await loop.execView<string>(dialog); // 'ok' when OK is pressed