# ui/uiinputfield (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/ui/uiinputfield/

입력 필드 (캔버스 기반).

## UIInputField extends WorldNode

입력 필드 (캔버스 기반).
- 텍스트 렌더링은 UILabel 자식 노드 두 개로 (값 라벨 + 플레이스홀더 라벨).
- 클릭/드래그/커서 이동/선택은 모두 캔버스 측에서 직접 처리.
- DOM <input> 사용 여부는 옵션 (setUseDOMInput, 기본 false). true 일 때만 한글 IME /
  모바일 소프트 키보드 / 시스템 클립보드가 동작. false 면 ASCII 위주 키보드 직접 처리.
- 우클릭 시 컨텍스트 메뉴 (잘라내기 / 복사 / 붙여넣기 / 모두 선택). 직접 누름(setUseDirectTouch) 필드도 브라우저 편집 칸 메뉴 대신 같은 메뉴다.
- 커서 이동과 Delete 는 크롬처럼 글자 묶음 단위, 뒤로 지우기는 블링크 BackspaceStateMachine 처럼 코드 포인트 하나(이모지 묶음은 통째로).
- DOM 입력은 크롬 입력 칸처럼 마우스로 두 번 누르면 낱말(윈도우는 뒤 공백까지), 세 번 누르면 글 전체를 고른다. (누름 수는 mousedown 의 detail)
- 캔버스 모드의 낱말 이동과 지우기는 크롬처럼 윈도우와 리눅스는 Ctrl, 맥은 Option 과 왼쪽, 오른쪽 화살표, Backspace, Delete 다. (블링크 NextWordPosition, PreviousWordPosition)
- 되돌리기와 다시 하기는 두 모드 모두 엔진이 이력을 맡는다. (러스트 판 TextEditBuffer 와 같은 블링크 묶음 규칙: 이어 친 글자는 한 번에, 커서를 옮기거나 선택을 바꾸면 끊긴다,
  새 편집은 다시 하기 목록을 지운다, setText 는 목록을 비운다) 키는 Ctrl(맥은 Cmd) + Z, Ctrl(맥은 Cmd) + Shift + Z, 윈도우와 리눅스는 Ctrl + Y, 윈도우는 Alt + Backspace 도.
  DOM 입력은 브라우저의 되돌리기 키와 historyUndo, historyRedo 를 막고 엔진 이력으로 한다. IME 조합 중에는 되돌리지 않는다.
- setMultiline(true) 면 크롬 textarea 같은 여러 줄 입력이다. (DOM 입력은 숨긴 textarea) 글은 white-space: pre-wrap, overflow-wrap: break-word 처럼
  줄바꿈 문자와 폭으로 나눈다. 줄 나눔 자리는 크롬 자신의 줄 나누기에서 읽는다. (러스트 판 ui/textarealayout.rs 와 같은 셈)
  Enter 는 줄을 넣고, 위아래와 page 는 엔진 배치로 옮기고, Home 과 End 는 보이는 줄의 앞과 끝, Ctrl(맥은 Cmd) + Home, End 는 글 앞과 끝이다. 넘치면 커서가 보이게 스크롤한다.

예제: 이름 입력칸 만들기

```js
import { Engine, EngineConfiguration, UIScene, UIInputField, Vector2 } from "./build/vanilla.js";

class MainScene extends UIScene {
	constructor() {
		super();
		this.setLoadingMinDurationMs(0);
	}

	initialize(engine) {
		super.initialize(engine);
		const inputField = new UIInputField();
		inputField.setEngine(engine);
		inputField.setLocalPosition(Vector2.create(40, 40));
		inputField.setContentSize(Vector2.create(320, 56));
		inputField.setPlaceholder("Your name");
		inputField.setMaxLength(16);
		inputField.setOnChange((value) => {
			console.log("change", value);
		});
		inputField.setOnSubmit((value) => {
			console.log("submit", value);
		});
		const root = this.getRoot();
		root.addChild(inputField);
		inputField.attach();
		inputField.setText("Player");
		console.log(inputField.getText(), inputField.getCursorIndex());
	}
}

const engineConfiguration = new EngineConfiguration();
engineConfiguration.canvasId = "mainCanvas";
engineConfiguration.referenceResolutionSize = Vector2.create(640, 360);
engineConfiguration.autoResizeOnWindowResize = true;
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());
```

- `constructor()` (constructor, since 0.2.1): 생성.
- `setEngine(engine)` (method, since 0.2.1): 설정.
  - `engine` Engine: 엔진. (DOM 입력의 자리, 캔버스 사건, 문맥 메뉴에 쓴다, 주지 않으면 Engine.getEngine() 을 쓴다)
- `setUseDOMInput(use)` (method, since 0.2.1): DOM 입력 사용 설정. (attach 때 보므로 그 전에 정한다)
  - `use` boolean: 참이면 숨은 DOM input 으로 글을 받는다. (한글 IME, 모바일 화면 키보드, 시스템 클립보드가 된다, 기본 거짓)

  예제: 모바일 키보드와 IME 로 받는 입력칸

  ```js
  import { Engine, EngineConfiguration, UIScene, UIInputField, Vector2 } from "./build/vanilla.js";
  
  class MainScene extends UIScene {
  	constructor() {
  		super();
  		this.setLoadingMinDurationMs(0);
  	}
  
  	initialize(engine) {
  		super.initialize(engine);
  		const inputField = new UIInputField();
  		inputField.setEngine(engine);
  		inputField.setUseDOMInput(true);
  		inputField.setUseTouchEndFocus(true);
  		inputField.setLocalPosition(Vector2.create(40, 40));
  		inputField.setContentSize(Vector2.create(320, 56));
  		inputField.setPlaceholder("Message");
  		const root = this.getRoot();
  		root.addChild(inputField);
  		inputField.attach();
  		console.log(inputField.isUsingDOMInput(), inputField.isFocused());
  	}
  }
  
  const engineConfiguration = new EngineConfiguration();
  engineConfiguration.canvasId = "mainCanvas";
  engineConfiguration.referenceResolutionSize = Vector2.create(640, 360);
  engineConfiguration.autoResizeOnWindowResize = true;
  const engine = new Engine(engineConfiguration);
  engine.run(new MainScene());
  ```

- `isUsingDOMInput()` (method, since 0.2.1): DOM 입력 사용 여부 반환.
  - returns boolean: DOM 입력을 쓰면 참.
- `setUseTouchEndFocus(use)` (method, since 0.3.2): DOM 입력일 때 손을 뗄 때(touchend)도 포커스를 줄지. (기본 false, 꺼져 있으면 touchstart 에서만 준다)
  켜면 사용자 활성화가 한 번도 없던 때(페이지의 첫 touchstart)에 얻은 포커스를 손을 뗄 때 다시 줘,
  그런 포커스에 키보드를 띄우지 않는 브라우저(안드로이드 크롬, 웹뷰)에서도 키보드가 뜨게 한다.
  - `use` boolean: 참이면 touchend 에서도 포커스를 준다. (기본 거짓)
- `isUsingTouchEndFocus()` (method, since 0.3.2): touchend 포커스 사용 여부 반환.
  - returns boolean: touchend 에서도 포커스를 주면 참.
- `setUseDirectTouch(use)` (method, since 0.3.2): DOM 입력을 필드 위에서 손가락(마우스)이 직접 누르게 할지. (기본 false, 꺼져 있으면 DOM 입력은 누름을 받지 않고 캔버스가 포커스를 준다)
  켜면 필드가 보이는 동안 투명한 DOM 입력이 필드 자리에서 누름을 받아, 브라우저의 기본 동작으로 포커스(다른 출처의 iframe 이면 그 프레임까지)와
  키보드를 연다. 코드로 준 포커스를 받지 않는 웹뷰(앱 안의 iframe 등)에서 쓴다. 포커스를 받으면 커서는 글 끝에 둔다.
  그 DOM 입력의 오른쪽 클릭은 브라우저 편집 칸 메뉴 대신 다른 필드와 같은 엔진 문맥 메뉴를 띄운다. (러스트 데스크탑과 같은 항목)
  - `use` boolean: 참이면 투명한 DOM 입력이 필드 자리에서 누름을 직접 받는다. (기본 거짓)
- `isUsingDirectTouch()` (method, since 0.3.2): 직접 누름 사용 여부 반환.
  - returns boolean: DOM 입력이 누름을 직접 받으면 참.
- `setMultiline(isMultiline)` (method, since 0.4.0): 여러 줄 설정. (크롬 textarea 처럼, DOM 입력은 숨긴 textarea 를 쓴다, 바꾸면 스크롤을 처음으로)
  - 여러 줄이면 Enter 가 줄을 넣고(제출 콜백을 부르지 않는다), 글을 폭에 맞춰 나누고, 위아래로 옮기고, 넘치면 스크롤한다.
  - UI 문서에 적는 원본 필드 속성이 아니다. (러스트 판도 반사에서 뺀다)
  - `isMultiline` boolean: 참이면 여러 줄, 거짓이면 한 줄. (처음 거짓)

  예제: 여러 줄 메모 칸

  ```js
  import { Engine, EngineConfiguration, UIScene, UIInputField, Vector2 } from "./build/vanilla.js";
  
  class MainScene extends UIScene {
  	constructor() {
  		super();
  		this.setLoadingMinDurationMs(0);
  	}
  
  	initialize(engine) {
  		super.initialize(engine);
  		const inputField = new UIInputField();
  		inputField.setEngine(engine);
  		inputField.setMultiline(true);
  		inputField.setTabSize(4);
  		inputField.setLineHeight(32);
  		inputField.setLocalPosition(Vector2.create(40, 40));
  		inputField.setContentSize(Vector2.create(320, 160));
  		inputField.setPlaceholder("Memo");
  		const root = this.getRoot();
  		root.addChild(inputField);
  		inputField.attach();
  		inputField.setText("first line\nsecond line");
  		console.log(inputField.isMultiline(), inputField.getLineHeight(), inputField.getTabSize());
  	}
  }
  
  const engineConfiguration = new EngineConfiguration();
  engineConfiguration.canvasId = "mainCanvas";
  engineConfiguration.referenceResolutionSize = Vector2.create(640, 360);
  engineConfiguration.autoResizeOnWindowResize = true;
  const engine = new Engine(engineConfiguration);
  engine.run(new MainScene());
  ```

- `isMultiline()` (method, since 0.4.0): 여러 줄인지.
  - returns boolean: 여러 줄이면 참.
- `setLineHeight(lineHeight)` (method, since 0.4.0): 줄 높이 설정. (여러 줄 필드, null 이면 CSS normal 이다. 크롬처럼 첫째 글꼴의 위아래 길이와 줄 사이로 셈한다)
  - `lineHeight` number | null: 줄 높이. (내용 크기 단위, null 이면 CSS normal)
- `getLineHeight()` (method, since 0.4.0): 줄 높이 반환. (여러 줄 필드)
  - returns number: 줄 높이. (정하지 않았으면 CSS normal 로 잰 값, 잴 문서가 없으면 글꼴 크기의 1.2 배를 반올림한 값)
- `setTabSize(tabSize)` (method, since 0.4.0): 탭 크기 설정. (여러 줄 필드, 공백 몇 개 폭, CSS tab-size)
  - `tabSize` number: 탭 크기. (공백 몇 개 폭, 음수는 0, 기본 8)
- `getTabSize()` (method, since 0.4.0): 탭 크기 반환.
  - returns number: 탭 크기. (공백 몇 개 폭)
- `getScrollTop()` (method, since 0.4.0): 위로 굴려 넘긴 만큼 반환. (여러 줄 필드, textarea scrollTop)
  - returns number: 위로 넘긴 만큼. (내용 크기 단위)
- `setScrollTop(scrollTop)` (method, since 0.4.0): 위로 굴려 넘기기. (여러 줄 필드, 다음 그리기에서 글 끝 안으로 줄인다)
  - `scrollTop` number: 위로 넘길 만큼. (내용 크기 단위, 음수는 0)
- `canUndo()` (method, since 0.4.0): 되돌릴 것이 있는지.
  - returns boolean: 되돌릴 묶음이 있으면 참.

  예제: 이어 친 글자를 한 번에 되돌리기

  ```js
  import { Engine, EngineConfiguration, UIScene, UIInputField, Vector2 } from "./build/vanilla.js";
  
  class MainScene extends UIScene {
  	constructor() {
  		super();
  		this.setLoadingMinDurationMs(0);
  	}
  
  	initialize(engine) {
  		super.initialize(engine);
  		const inputField = new UIInputField();
  		inputField.setEngine(engine);
  		inputField.setLocalPosition(Vector2.create(40, 40));
  		inputField.setContentSize(Vector2.create(320, 56));
  		const root = this.getRoot();
  		root.addChild(inputField);
  		inputField.attach();
  		inputField.replaceSelection("a");
  		inputField.replaceSelection("b");
  		console.log(inputField.getText(), inputField.canUndo(), inputField.canRedo());
  	}
  }
  
  const engineConfiguration = new EngineConfiguration();
  engineConfiguration.canvasId = "mainCanvas";
  engineConfiguration.referenceResolutionSize = Vector2.create(640, 360);
  engineConfiguration.autoResizeOnWindowResize = true;
  const engine = new Engine(engineConfiguration);
  engine.run(new MainScene());
  ```

- `canRedo()` (method, since 0.4.0): 다시 할 것이 있는지.
  - returns boolean: 다시 할 묶음이 있으면 참.
- `setText(text)` (method, since 0.2.1): 값 설정. (최대 길이를 넘으면 서로게이트 쌍을 쪼개지 않는 데까지 자르고 커서를 끝에 둔다, 바뀜 콜백은 부르지 않는다, 되돌리기와 다시 하기 목록과 조합 중인 글을 비운다)
  - `text` string: 넣을 글. (거짓 값이면 빈 글, 그 밖은 String 으로 바꾼다)
- `getText()` (method, since 0.2.1): 값 반환.
  - returns string: 입력한 글. (조합 중인 글은 빠진다)
- `setPlaceholder(text)` (method, since 0.2.1): 플레이스홀더 설정.
  - `text` string: 값이 비었을 때 보일 글. (거짓 값이면 빈 글)
- `setMaxLength(n)` (method, since 0.2.1): 최대 길이 설정.
  - `n` number: 최대 글자 수. (글의 length 로 센다, 소수는 버린다, 0 이하면 제한하지 않는다, 지금 값은 자르지 않는다)
- `setFontSize(size)` (method, since 0.2.1): 글자 크기 설정.
  - `size` number: 글자 크기. (내용 크기 단위, 기본 28)
- `setFont(font)` (method, since 0.2.1): 글꼴 설정.
  - `font` FontFace | FontAsset | null: 글꼴. (FontAsset 이면 그 fontFace, null 이나 undefined 면 시스템 글꼴, 그 밖의 꼴은 무시한다)
- `setPadding(padding)` (method, since 0.2.1): 안쪽 여백 설정.
  - `padding` number: 왼쪽과 오른쪽 안쪽 여백. (내용 크기 단위, 기본 16)
- `setBackgroundColor(color)` (method, since 0.2.1): 배경색 설정.
  - `color` Color | string: 배경색. (기본 흰색)
- `setRoundSize(roundSize)` (method, since 0.2.1): 모서리 둥글기 설정.
  - `roundSize` number: 배경과 포커스 테두리의 모서리 반지름. (기본 8)
- `setTextColor(color)` (method, since 0.2.1): 글자 색 설정.
  - `color` Color | string: 값 글자의 색. (기본 #222222)
- `setPlaceholderColor(color)` (method, since 0.2.1): 플레이스홀더 색 설정.
  - `color` Color | string: 플레이스홀더 글자의 색. (기본 #999999)
- `setCursorColor(color)` (method, since 0.2.1): 커서 색 설정. (조합 중 밑줄 색도 함께 바꾼다)
  - `color` Color | string: 커서와 조합 밑줄의 색. (기본 #5b8def)
- `setFocusBorderColor(color)` (method, since 0.2.1): 포커스 테두리 색 설정.
  - `color` Color | string: 포커스 테두리 색. (기본 #f97316)
- `setFocusBorderWidth(width)` (method, since 0.2.1): 포커스 테두리 두께 설정.
  - `width` number: 포커스 테두리 두께. (0 이하면 그리지 않는다, 기본 3)
- `setSelectionColor(color)` (method, since 0.2.1): 선택 영역 색 설정.
  - `color` Color | string: 선택 영역을 칠할 색. (기본 알파 0.35 의 파랑)
- `getPlaceholder()` (method, since 0.4.0): 플레이스홀더 반환.
  - returns string: 플레이스홀더 글.
- `getMaxLength()` (method, since 0.4.0): 최대 길이 반환.
  - returns number: 최대 글자 수. (0 이면 제한하지 않는다)
- `getFontSize()` (method, since 0.4.0): 글자 크기 반환.
  - returns number: 글자 크기.
- `getPadding()` (method, since 0.4.0): 안쪽 여백 반환.
  - returns number: 왼쪽과 오른쪽 안쪽 여백.
- `getBackgroundColor()` (method, since 0.4.0): 배경색 반환.
  - returns Color: 배경색.
- `getRoundSize()` (method, since 0.4.0): 모서리 둥글기 반환.
  - returns number: 배경의 모서리 반지름.
- `getTextColor()` (method, since 0.4.0): 글자 색 반환.
  - returns Color: 값 글자의 색.
- `getPlaceholderColor()` (method, since 0.4.0): 플레이스홀더 색 반환.
  - returns Color: 플레이스홀더 글자의 색.
- `getCursorColor()` (method, since 0.4.0): 커서 색 반환.
  - returns Color: 커서 색.
- `getCursorIndex()` (method, since 0.4.0): 커서 자리 반환.
  - returns number: 커서 자리. (값 안의 글자 위치, 0 ~ 값 길이)
- `getSelectionStart()` (method, since 0.4.0): 선택 시작 자리 반환.
  - returns number: 선택의 고정 끝. (커서 자리와 같으면 선택이 없다)
- `getComposition()` (method, since 0.4.0): 조합 중인 글 반환.
  - returns string: IME 가 조합 중인 글. (없으면 빈 글)
- `getDisplayText()` (method, since 0.4.0): 보이는 글 반환. (값의 커서 자리에 조합 글을 끼운 것, 고른 채 조합하면 고른 글 자리를 조합 글로 갈음한 것)
  - returns string: 보이는 글. (조합 중이 아니면 값 그대로)
- `isComposing()` (method, since 0.4.0): IME 조합 중인지.
  - returns boolean: 조합 중이면 참.
- `setOnChange(callback)` (method, since 0.2.1): 바뀜 콜백 설정.
  - `callback` (value: string) => void: 사용자 입력으로 값이 바뀔 때마다 부를 함수. (인자는 새 값, setText 로 바꿀 때는 부르지 않는다, null 이면 부르지 않는다)
- `setOnSubmit(callback)` (method, since 0.2.1): 제출 콜백 설정.
  - `callback` (value: string) => void: 포커스된 채 Enter 를 누르면 부를 함수. (인자는 지금 값, null 이면 부르지 않는다)
- `attach()` (method, since 0.2.1): 입력 라이프사이클: 활성화(attach) / 비활성화(detach).
- `detach()` (method, since 0.2.1): 입력 끄기. (DOM 입력, 키보드, 문맥 메뉴 사건을 떼고 메뉴를 닫는다)
- `focus()` (method, since 0.2.1): 외부 API.
- `blur()` (method, since 0.2.1): 포커스 풀기.
- `isFocused()` (method, since 0.2.1): 포커스 여부 반환.
  - returns boolean: 포커스를 가졌으면 참.
- `selectAll()` (method, since 0.2.1): 모두 선택.
- `tick(timeDelta)` (method, since 0.2.1): 매 프레임: 라벨 위치 / 텍스트 동기, DOM 위치 동기, 커서 깜빡임, selection 폴링.
  - `timeDelta` number: 지난 프레임부터의 시간. (초)
- `touchPress(viewInputPosition)` (method, since 0.2.1): 캔버스 측 터치 (포지션 기반 커서 / 드래그 선택). pointer-events: none 인 DOM input
  이 클릭을 가로채지 않으므로 항상 여기로 들어옴.
  - `viewInputPosition` Vector2: 누른 자리. (뷰 좌표)
- `touchMove(viewInputPosition)` (method, since 0.2.1): 터치 이동. (누른 자리부터 지금 자리까지 선택한다)
  - `viewInputPosition` Vector2: 옮긴 자리. (뷰 좌표)
- `touchRelease()` (method, since 0.2.1): 터치 뗌. (끌어 선택하기를 끝낸다)
- `touchCancel()` (method, since 0.2.1): 터치 취소. (끌어 선택하기를 끝낸다)
- `measureIndexAtLocalX(localX)` (method, since 0.2.1): localX(노드 로컬 X) → 문자 인덱스. 측정은 오프스크린 2D ctx 로.
    (메인 캔버스는 WebGL2 컨텍스트라 2D 측정 불가)
  - `localX` number: 노드 안의 X. (내용 영역 왼쪽이 0)
  - returns number: 그 자리에 가장 가까운 글자 묶음 경계. (UTF-16 단위, 0 ~ 값 길이, 잴 컨텍스트가 없으면 값 길이)
- `handleCanvasKeydown(event)` (method, since 0.2.1): 캔버스 모드 키 입력 처리. (포커스일 때만, Ctrl 이나 Cmd 와 A, C, X, V, 지우기, 화살표, Home, End, Enter, 글자 한 개)
  - `event` KeyboardEvent: 문서의 keydown 사건.
- `moveCursor(newIndex, extendSelection)` (method, since 0.2.1): 커서 옮기기.
  - `newIndex` number: 옮길 자리. (UTF-16 단위, 0 ~ 값 길이로 자른다, 서로게이트 쌍 가운데면 그 글자 뒤로 본다)
  - `extendSelection` boolean: 참이면 선택의 고정 끝을 두고 선택을 늘린다.
- `hasSelection()` (method, since 0.2.1): 선택 / 클립보드.
  - returns boolean: 선택한 글이 있으면 참.
- `getSelectionRange()` (method, since 0.2.1): 선택 범위 반환.
  - returns { start: number, end: number } | null: 선택 범위. (start 가 작은 쪽, 선택이 없으면 null)
- `getSelectionText()` (method, since 0.2.1): 선택한 글 반환.
  - returns string: 선택한 글. (없으면 빈 글)
- `replaceSelection(text)` (method, since 0.2.1): 선택을 글로 바꾸기. (선택이 없으면 커서 자리에 끼운다, 바뀜 콜백을 부른다)
  - 최대 길이가 있으면 블링크 입력 칸처럼 넣는 글을 남은 길이까지만 넣는다. (서로게이트 쌍은 쪼개지 않는다)
  - `text` string: 넣을 글. (빈 글이면 선택을 지운다, 글자 넣기 되돌리기 묶음이다)
- `cut()` (method, since 0.2.1): 잘라내기. (선택한 글을 클립보드에 쓰고 지운다, 선택이 없으면 아무것도 하지 않는다)
- `copy()` (method, since 0.2.1): 복사. (선택한 글을 클립보드에 쓴다, 선택이 없으면 아무것도 하지 않는다)
- `paste()` (method, since 0.2.1): 붙여넣기. (클립보드 글을 비동기로 읽어 선택 자리에 넣는다, 읽지 못하거나 비었으면 무시한다)
- `requestMenuAction(menuAction)` (method, since 0.4.0): 문맥 메뉴 항목 부탁. (다음 tick 에 한다, UIInputFieldMenuAction)
  - `menuAction` string: 할 항목. (UIInputFieldMenuAction 의 값)

  예제: 게임의 메뉴에서 복사 부탁하기

  ```js
  import { Engine, EngineConfiguration, UIScene, UIInputField, UIInputFieldMenuAction, Vector2 } from "./build/vanilla.js";
  
  class MainScene extends UIScene {
  	constructor() {
  		super();
  		this.setLoadingMinDurationMs(0);
  	}
  
  	initialize(engine) {
  		super.initialize(engine);
  		const inputField = new UIInputField();
  		inputField.setEngine(engine);
  		inputField.setLocalPosition(Vector2.create(40, 40));
  		inputField.setContentSize(Vector2.create(320, 56));
  		const root = this.getRoot();
  		root.addChild(inputField);
  		inputField.attach();
  		inputField.setText("Invite code 1234");
  		inputField.selectAll();
  		inputField.requestMenuAction(UIInputFieldMenuAction.copy);
  		console.log(inputField.getSelectionText());
  	}
  }
  
  const engineConfiguration = new EngineConfiguration();
  engineConfiguration.canvasId = "mainCanvas";
  engineConfiguration.referenceResolutionSize = Vector2.create(640, 360);
  engineConfiguration.autoResizeOnWindowResize = true;
  const engine = new Engine(engineConfiguration);
  engine.run(new MainScene());
  ```

- `showContextMenu(viewPosition)` (method, since 0.2.1): 문맥 메뉴 띄우기. (엔진이 그린 잘라내기, 복사, 붙여넣기, 모두 선택 메뉴, 러스트 판 show_context_menu 와 같다)
  - 루트의 마지막 자식 노드(UIInputFieldContextMenu 컴포넌트)로 만들어 위에 그린다. 메뉴 왼쪽 위가 누른 자리다.
  - 메뉴 밖을 누르거나, 필드가 포커스를 잃거나 트리에서 빠지면 닫힌다.
  - `viewPosition` Vector2: 메뉴 왼쪽 위. (뷰 좌표)

## UIInputFieldMenuAction (enum)

문맥 메뉴 항목. (잘라내기 / 복사 / 붙여넣기 / 모두 선택, requestMenuAction 이 받는다)

- `cut` = `cut`: 잘라내기.
- `copy` = `copy`: 복사.
- `paste` = `paste`: 붙여넣기.
- `selectAll` = `selectAll`: 모두 선택.
