Skip to content

@jsvision/ui / okButton

Function: okButton()

okButton(i18n?): Button

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

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

Parameters

i18n?

I18n

Translation service for the built-in label; defaults to isolated English UI text.

Returns

Button

A Button labelled OK.

Example

ts
import { Dialog, okButton, cancelButton, createEventLoop, at } 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 = at(okButton(), 6, 4, 10, 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