Skip to content

TextField

TextField is a single-line text input backed by an <input type="text"> element. It implements Bindable<string>, so it can participate in a Binding directly.

Usage

typescript
import { Event } from '@jimka/typescript-ui/core';
import { TextField } from '@jimka/typescript-ui/component/input';
const nameField = TextField();
nameField.setValue('');
nameField.setPreferredSize(240, 28);

Event.addListener(nameField, 'input', () => {
    console.log('value:', nameField.getValue());
});

panel.addComponent(nameField);

Common methods

MethodPurpose
getValue() / setValue(text)Read / write the field's text.
setText(text) / getText()Alias retained from the abstract base.
addBindingListener(fn)Subscribe to user-driven changes (used by Binding).
select()Select all current text.

Binding

typescript
import { Binding } from '@jimka/typescript-ui/core';
const binding = new Binding().bind('name', nameField);
binding.setRecord(store.getAt(0));

See also