Skip to content

Latest commit

 

History

History
266 lines (175 loc) · 5.25 KB

text-view.md

File metadata and controls

266 lines (175 loc) · 5.25 KB
title description contributors
TextView
UI component for multi-line text entry.
rigor789
Ombuweb

<TextView> is a UI component for multi-line text entry. When set to read-only, it can also be used to display multi-line text.

For single-line text input, see TextField.

::: code-group <<< @/../examples/typescript/src/ui/TextView/template.xml#example [XML] <<< @/../examples/typescript/src/ui/TextView/template.ts#example [TypeScript] :::

::: code-group <<< @/../examples/angular/src/ui/TextView/component.html#example [HTML] <<< @/../examples/angular/src/ui/TextView/component.ts#example [TypeScript] :::

<<< @/../examples/react/src/components/ui/textview.tsx#example

<<< @/../examples/solid/src/ui/textview.tsx#example

<<< @/../examples/svelte/app/components/ui/TextView.svelte#example

<<< @/../examples/vue/src/ui/TextView/component.vue#example

Examples

Formatting text inside a TextView

If you need to style parts of the text, you can use a combination of a FormattedString and Span elements.

<TextView>
  <FormattedString>
    <Span text="This text has a " />
    <Span text="red " style="color: red" />
    <Span text="piece of text. " />
    <Span text="Also, this bit is italic, " fontStyle="italic" />
    <Span text="and this bit is bold." fontWeight="bold" />
  </FormattedString>
</TextView>

Props

text

text: string

Gets or sets the text of the TextView.

hint

hint: string

Gets or sets the placeholder text for the TextView.

editable

editable: boolean

When set to false the TextView is read-only.

Defaults to true.

keyboardType

keyboardType: CoreTypes.KeyboardType | number // "datetime" | "email" | "integer" | "number" | "phone" | "url"

Gets or sets the keyboard type shown when editing this TextView.

On iOS, any valid UIKeyboardType number works, for example:

keyboardType = 8 // UIKeyboardType.DecimalPad

See CoreTypes.KeyboardType, UIKeyboardType.

returnKeyType

returnKeyType: CoreTypes.ReturnKeyType // "done" | "go" | "next" | "search" | "send"

Gets or sets the label of the return key.

See CoreTypes.ReturnKeyType.

isEnabled

Allows disabling the TextView. A disabled TextView does not react to user gestures or input.

Default value is true.

maxLines

maxLines: number

Limits input to the specified number of lines.

autocorrect

autocorrect: boolean

Enables or disables autocorrect.

isWritingToolsActive 8.9+

(iOS Only) Are Apple Intelligence writing tools active.

isWritingToolsActive: boolean

enableWritingToolsEvents 8.9+

(iOS Only) Allow Apple Intelligence writing tools to emit text changes on each alteration instead of after the final change (default).

enableWritingToolsEvents: boolean

iosWritingToolsBehavior 8.9+

(iOS Only) Behavior for Apple Intelligence Writing Tools.

iosWritingToolsBehavior: WritingToolsBehavior

Can be Default, Complete, Limited or None.

iosWritingToolsAllowedInput 8.9+

(iOS Only) Allowed input for Apple Intelligence Writing Tools.

iosWritingToolsAllowedInput: Array<WritingToolsAllowedInput>

Can be Default, List, PlainText, RichText or Table.

...Inherited

For additional inherited properties not shown, refer to the API Reference.

Methods

focus()

focus(): boolean

Focuses the TextView and returns true if the focus was succeessful.

dismissSoftInput()

dismissSoftInput(): void

Hides the on-screen keyboard.

Events

textChange

on('textChange', (args: PropertyChangeData) => {
  const textView = args.object as TextView
  console.log('TextView text changed:', args.value)
})

Emitted when the input text changes.

Event data type: PropertyChangeData

returnPress

on('returnPress', (args: EventData) => {
  const textView = args.object as TextView
  console.log('TextView return key pressed.')
})

Emitted when the return key is pressed.

focus

on('focus', (args: EventData) => {
  const textView = args.object as TextView
  console.log('TextView has been focused')
})

Emitted when the TextView gains focus.

blur

on('blur', (args: EventData) => {
  const textView = args.object as TextView
  console.log('TextView has been blured')
})

Emitted when the TextView loses focus.

Native component