ui/uiinputfield
입력 필드. (원본 ui/uiinputfield.js 의 UIInputField, BackgroundLayerRenderer, OverlayLayerRenderer)
- 글, 커서, 선택 영역, IME 조합 글과 밑줄, 포커스 테두리를 캔버스에 직접 그리고, 누르기와 끌기로 커서와 선택을 정한다.
- 원본은 WorldNode 를 상속한 노드이고, 글은 UILabel 자식 노드 두 개(값, 안내 글), 커서와 테두리는 오버레이 자식 노드가 그린다. 러스트 판은 다른 위젯처럼 컴포넌트다. node_tree.add_component(node_id, UIInputField::new()) 로 붙인다. UIControl 을 품어 attach_to_tree 에서 content 노드를 만들고 호스트를 interactable 로 켠다. 피봇과 앵커는 원본처럼 왼쪽 위로 맞춘다. 글은 Text 두 개(값, 안내 글)를 품어 그리고, 바탕(원본 Paint 컴포넌트)도 품은 Paint 로 그린다. 층 순서는 원본과 같다: 바탕 → 선택 영역 → 글 → 조합 밑줄 → 커서 → 포커스 테두리. 한 컴포넌트가 한 번에 그려서 씬 코드가 tick 밖에서 set_text 를 불러도 그 프레임에 바로 보인다. (자식 노드로 나누면 상태를 옮기느라 한 프레임 늦는다)
- 입력은 엔진의 글 입력 줄(core/textinput.rs)에서 받는다. 포커스를 가진, attach() 한 필드가 tick 에서 꺼내 쓴다.
- 데스크탑: winit 의 KeyboardInput 과 Ime 이벤트. use_dom_input(원본 setUseDOMInput)이 켜진 필드가 포커스를 가질 때만 IME 가 켜진다.
- 웹: 원본처럼 필드마다 숨긴 DOM <input> 을 필드 위에 둔다. (platform/web/textinput.rs) 값과 선택은 DOM 이 주인이고 필드가 따라간다. use_dom_input 이 꺼진 필드는 원본 캔버스 모드처럼 window keydown 으로 받는다.
- 원본과 다른 것:
- 이벤트는 Box<dyn FnMut(&mut UIInputField, &mut ComponentContext)> 다. 원본 콜백은 값만 받는다. (값은 field.get_text())
- setFont(FontFace) 는 set_font_family(등록한 폰트 이름) 로 바꿨다. setEngine 은 옮기지 않았다. (엔진은 문맥으로 받는다)
- 공개 함수의 글자 자리(get_cursor_index, get_selection_start, get_selection_range, move_cursor, measure_index_at_local_x)와 max_length 는 원본처럼 UTF-16 단위로 센다. 안에서는 문자(char) 단위로 들어 서로게이트 쌍(이모지 같은 글자)을 쪼개지 않는다. 그래서 UTF-16 자리가 서로게이트 쌍 가운데면 그 글자 뒤로 본다. (원본도 같다) max_length 가 있으면 블링크 입력 칸처럼 넣는 글을 남은 길이까지만 넣는다.
- 누른 자리 → 글자 자리는 draw 때 재 둔 글자 경계로 찾는다. (원본은 오프스크린 2D 캔버스로 그때그때 잰다)
- 데스크탑에서는 use_dom_input 이 켜진 필드도 원본 DOM 모드처럼 필드 밖을 누르면 포커스를 잃는다. 포커스는 엔진에 하나뿐이다. (원본 캔버스 모드는 다른 필드를 눌러도 앞 필드가 포커스를 쥐고 있다. 러스트 판은 나중에 포커스를 얻은 필드만 남긴다)
- 포커스를 잃을 때 조합 중이던 글은 확정해 값에 넣는다. (브라우저가 DOM 입력에 하는 일과 같다)
- 문맥 메뉴(오른쪽 단추)는 원본처럼 엔진이 그린다. (UIInputFieldContextMenu, 웹과 데스크탑 같다) 루트의 마지막 자식 노드로 만들어 위에 그린다. 항목은 원본처럼 잘라내기, 복사, 붙여넣기, 모두 선택이다. DOM 입력을 직접 누르게 한 필드(use_direct_touch)도 원본처럼 브라우저 편집 칸 메뉴 대신 같은 메뉴다. 그 필드는 크롬 데스크탑 터치처럼 손가락 길게 누르기(650ms, 15 DIP 안)로 낱말을 고르고 터치 손잡이와 빠른 메뉴를 띄운다. (윈도우는 뗄 때 메뉴를 정한다)
- 데스크탑 DOM 입력 필드는 원본 DOM 입력 칸처럼 되돌리기와 다시 하기를 한다. (Ctrl+Z, Ctrl+Shift+Z, Ctrl+Y, 맥은 Cmd, 블링크의 묶음 규칙, TextEditBuffer)
- 데스크탑 한 줄 DOM 입력 필드는 블링크 입력 칸처럼 넣는 글의 끝 줄바꿈을 지우고 가운데 줄바꿈을 공백으로 바꾸고, 위와 page 위는 글 앞, 아래와 page 아래는 글 끝으로 옮긴다.
- set_multiline(true) 면 크롬 textarea 같은 여러 줄 입력이다. (원본 엔진에는 없고, 원본은 Pane 의 textarea 프리셋으로 DOM textarea 를 쓴다) 글은 white-space: pre-wrap, overflow-wrap: break-word 처럼 줄바꿈 문자와 폭으로 나눈다. (ui/textarealayout.rs, 줄 나눔 자리는 크롬처럼 유니코드 줄 나누기) Enter 는 줄을 넣고(글자 넣기 되돌리기 묶음), 위아래는 첫 위아래 이동 때의 가로 자리를 지키며(첫 줄 위는 글 앞, 마지막 줄 아래는 글 끝), Home 과 End 는 보이는 줄의 앞과 끝(맥은 Cmd + 왼쪽, 오른쪽도), Ctrl + Home, End(맥은 Cmd + 위, 아래)는 글 앞과 끝, PageUp, PageDown(맥은 Option 과 함께)은 보이는 높이의 87.5%(맥은 높이 - 40 과 견줘 큰 쪽) 안의 가장 먼 줄로 옮겨 그 줄을 맨 위로 올린다. 넣는 글의 CR, CRLF 는 LF 로 바꾼다. 커서는 편집과 이동 뒤 보이게 스크롤하고(맥이 아니면 가장자리, 맥은 가운데), 휠과 썸 끌기로 넘긴다. 줄 높이의 normal 은 크롬처럼 첫째 글꼴의 위아래 길이와 줄 사이로 셈한다. 스크롤 막대는 크롬처럼 클래식 막대(윈도우, 리눅스, 맥 클래식 설정)면 넘칠 때 글 폭을 던다. 맥 Home, End 는 크롬 맥처럼 커서를 두고 처음과 끝으로 넘기고(넘길 것이 없으면 줄 앞과 끝), PageUp, PageDown 은 커서를 두고 한 화면만큼 넘긴다.
- DOM 입력을 흉내 내는 필드(use_dom_input, 여러 줄)는 크롬처럼 마우스로 두 번 누르면 낱말(윈도우는 뒤 공백까지), 세 번 누르면 문단을 고르고 끌면 그 단위로 넓힌다. 이어 누르기는 크롬 aura 처럼 500ms(맥은 시스템의 두 번 클릭 시간) 안, 가로 세로 2 DIP 안이다. 웹은 브라우저가 센 mousedown 의 detail 을 쓴다.
- 커서 이동과 Delete 는 크롬처럼 글자 묶음(확장 자소 묶음) 단위, 뒤로 지우기는 블링크 BackspaceStateMachine(코드 포인트 하나, 이모지 묶음은 통째로)이다. 웹 DOM 입력은 숨긴
<textarea>가 글, 조합, 되돌리기를 맡고, 보이는 줄로 옮기는 키(위아래, page, Home, End)는 필드가 엔진 배치로 옮긴다. - 낱말 이동과 지우기(윈도우와 리눅스 Ctrl, 맥 Option 과 왼쪽, 오른쪽, Backspace, Delete)는 크롬 textarea 처럼 블링크 NextWordPosition, PreviousWordPosition 대로다. (오른쪽은 윈도우만 다음 낱말 앞, 맥과 리눅스는 지금 낱말 끝. 맥은 넓히던 고르기가 고정 끝을 넘지 않는다) 웹 DOM 입력은 브라우저가 한다.
- 노드를 끄거나(set_active(false)) 지우면 tick 이 돌지 않아 포커스와 IME, 웹의 숨긴 <input> 이 함께 사라진다. (원본은 detach 해야 사라진다)
- getRenderState 는 옮기지 않았다. (그리는 컴포넌트가 하나라 넘길 일이 없다)
- UI 문서(UIDocument)는 register_node_type 으로 등록하면 원본 노드 꼴로 쓰고 읽는다. (노드 type "UIInputField", 바탕 Paint, 그리기 층, 안내 글과 값 UILabel 자식, 오버레이 자식. uidocument.rs 의 UIDocumentNode) 러스트 판이 만드는 content 노드는 문서에 적지 않는다. 글 라벨과 오버레이의 자리와 크기는 원본 refreshTextPositions 처럼 tick 이 마지막으로 놓은 노드 크기(text_layout_size)로 적는다.
Input field. (UIInputField, BackgroundLayerRenderer, OverlayLayerRenderer of the original ui/uiinputfield.js)
- Draws text, cursor, selection, IME composition text and its underline, and the focus border directly onto the canvas, and sets the cursor and selection by pressing and dragging.
- The original is a node inheriting WorldNode, with text drawn by two UILabel child nodes (value, placeholder) and the cursor and border drawn by an overlay child node. The Rust version is a component like the other widgets. Attach it with node_tree.add_component(node_id, UIInputField::new()). It contains a UIControl, creates the content node in attach_to_tree and turns the host interactable. The pivot and anchor are set to the top left as in the original. Text is drawn with two contained Text instances (value, placeholder), and the background (the original Paint component) is also drawn with a contained Paint. The layer order is the same as the original: background → selection → text → composition underline → cursor → focus border. One component draws them all at once, so even if scene code calls set_text outside tick, it shows up immediately that frame. (splitting into child nodes would lag one frame while moving the state)
- Input is received from the engine's text input queue (core/textinput.rs). The attach()ed field with focus takes it out in tick.
- Desktop: winit KeyboardInput and Ime events. IME is enabled only when a field with use_dom_input (the original setUseDOMInput) on has focus.
- Web: as in the original, a hidden DOM <input> is placed over each field. (platform/web/textinput.rs) The DOM owns the value and selection, and the field follows. Fields with use_dom_input off receive window keydown like the original canvas mode.
- Differences from the original:
- Events are Box<dyn FnMut(&mut UIInputField, &mut ComponentContext)>. Original callbacks receive only the value. (the value is field.get_text())
- setFont(FontFace) became set_font_family(registered font name). setEngine was not ported. (the engine comes from the context)
- Character positions in the public functions (get_cursor_index, get_selection_start, get_selection_range, move_cursor, measure_index_at_local_x) and max_length count in UTF-16 units as in the original. Internally they are held in characters (char) so surrogate pairs (characters like emoji) are not split. So a UTF-16 position in the middle of a surrogate pair is treated as after that character. (the original does the same) With max_length, inserted text is cut to the remaining length like a Blink input box.
- Pressed position → character position is found from the character boundaries measured during draw. (the original measures each time with an offscreen 2D canvas)
- On desktop, fields with use_dom_input on also lose focus when pressing outside the field, like the original DOM mode. There is only one focus in the engine. (in the original canvas mode, the previous field keeps focus even when another field is pressed. The Rust version keeps only the field that gained focus last)
- When focus is lost, text being composed is committed into the value. (same as what browsers do for DOM inputs)
- The context menu (right button) is drawn by the engine like the original. (UIInputFieldContextMenu, the same on the web and the desktop) It is created as the last child node of the root and drawn on top. The items are cut, copy, paste and select all, as in the original. Fields that let the DOM input be pressed directly (use_direct_touch) also get this menu instead of the browser edit-field menu, as in the original. Those fields select a word with a finger long press (650ms, within 15 DIP) like Chrome desktop touch and show touch handles and the quick menu. (Windows decides the menu on release)
- Desktop DOM input fields undo and redo like the original DOM input box. (Ctrl+Z, Ctrl+Shift+Z, Ctrl+Y, Cmd on Mac, Blink's grouping rules, TextEditBuffer)
- Desktop single-line DOM input fields, like a Blink input box, remove trailing line breaks from inserted text and replace middle line breaks with spaces, and up and page up move to the text start, down and page down to the text end.
- With set_multiline(true), it is a multiline input like Chrome textarea. (not in the original engine, where the original uses a DOM textarea through the textarea preset of Pane) Text is split by line break characters and width, like white-space: pre-wrap, overflow-wrap: break-word. (ui/textarealayout.rs, line break positions follow Unicode line breaking like Chrome) Enter inserts a line (in the character insertion undo group), up and down keep the horizontal position from the first vertical move (up on the first line goes to the text start, down on the last line to the text end), Home and End go to the start and end of the visible line (also Cmd + Left, Right on Mac), Ctrl + Home, End (Cmd + Up, Down on Mac) go to the text start and end, PageUp, PageDown (with Option on Mac) move to the farthest line within 87.5% of the visible height (on Mac, the larger of that and height - 40) and bring that line to the top. CR and CRLF in inserted text become LF. After edits and moves it scrolls to keep the cursor visible (to the edge except on macOS, to the center on macOS), and it scrolls with the wheel and thumb dragging. A normal line height is computed from the first font's ascent, descent and line gap like Chrome. With classic scroll bars (Windows, Linux, the macOS classic setting), the scroll bar takes away text width when overflowing, like Chrome. On macOS, Home and End leave the cursor and scroll to the start and end like Chrome on macOS (line start and end if there is nothing to scroll), and PageUp, PageDown leave the cursor and scroll by one screen.
- Fields imitating DOM input (use_dom_input, multiline) select a word (with the trailing space on Windows) on a double click and a paragraph on a triple click like Chrome, and dragging extends by that unit. Repeated presses are within 500ms (the system double-click time on macOS) and within 2 DIP horizontally and vertically, like Chrome aura. The web uses the mousedown detail counted by the browser.
- Cursor movement and Delete work by grapheme cluster (extended grapheme cluster) like Chrome, and Backspace follows Blink's BackspaceStateMachine (one code point, emoji sequences whole). For web DOM input, a hidden
<textarea>handles text, composition and undo, and keys that move by visible lines (up and down, page, Home, End) are handled by the field using the engine layout. - Word movement and deletion (Ctrl on Windows and Linux, Option on macOS, with Left, Right, Backspace, Delete) follow Blink NextWordPosition, PreviousWordPosition like Chrome's textarea. (Right goes to the start of the next word only on Windows, and to the end of the current word on macOS and Linux. On macOS, an extending selection does not cross the anchor) For web DOM input, the browser does it.
- Turning off (set_active(false)) or removing the node stops tick, so focus, IME and the web's hidden <input> go away together. (the original goes away only when detached)
- getRenderState was not ported. (there is only one drawing component, so there is nothing to pass)
- UI documents (UIDocument) write and read it in the original node form when registered with register_node_type. (node type "UIInputField", background Paint, draw layers, placeholder and value UILabel children, overlay child. UIDocumentNode in uidocument.rs) The content node the Rust version creates is not written to the document. The positions and sizes of the text labels and overlay are written from the node size last placed by tick (text_layout_size), like the original refreshTextPositions.
use vanilla::{TextEditBuffer, TextEditKind};
let mut buffer = TextEditBuffer::new();
buffer.set_text("abc");
buffer.begin_edit(TextEditKind::InsertText);
buffer.replace_selection("d");
buffer.begin_edit(TextEditKind::InsertText);
buffer.replace_selection("e");
assert_eq!(buffer.get_text(), "abcde");
assert!(buffer.undo());
assert_eq!(buffer.get_text(), "abc");
assert!(buffer.redo());
assert_eq!(buffer.get_text(), "abcde");
assert!(!buffer.can_redo());UIInputFieldEventtype
입력 필드 이벤트. (필드와 문맥을 받는다. 값은 field.get_text())
Input field event. (takes the field and the context. the value is field.get_text())
pub type UIInputFieldEvent = Box<dyn FnMut(&mut UIInputField, &mut ComponentContext)>TextEditBufferstruct traits Clone, Debug, Default
편집 버퍼. (값, 조합 글, 커서, 선택 시작. 원본 UIInputField 의 #value / #composition / #cursor_index / #selection_start 와 편집 함수)
- 자리는 문자 단위다. 커서와 선택 시작이 다르면 그 사이가 선택 영역이다. (커서가 앞일 수도 있다)
- max_length 는 원본 maxLength 처럼 UTF-16 단위다. (웹 DOM <input> 의 maxlength 와 같은 셈)
- 되돌리기와 다시 하기: 원본 DOM 입력 칸은 브라우저가 해 준다. 묶음은 블링크와 같다. (이어 친 글자는 한 번에, 커서를 옮기거나 선택을 바꾸면 끊긴다, 새 편집은 다시 하기 목록을 지운다, 값을 코드로 넣으면 목록을 비운다) 편집하는 쪽이 고치기 전에 begin_edit 를 부른다.
Edit buffer. (value, composition text, cursor, selection start. #value / #composition / #cursor_index / #selection_start of the original UIInputField and the edit functions)
- Positions are in characters. If the cursor and the selection start differ, the range between them is the selection. (the cursor may be in front)
- max_length is in UTF-16 units like the original maxLength. (the same count as maxlength of the web DOM <input>)
- Undo and redo: in the original DOM input field, the browser does it. Grouping is the same as Blink. (consecutively typed characters go at once, moving the cursor or changing the selection breaks it, a new edit clears the redo list, setting the value in code empties the lists) The editing side calls begin_edit before changing it.
use vanilla::TextEditBuffer;
let mut buffer = TextEditBuffer::new();
buffer.set_max_length(5);
buffer.set_text("hello world");
assert_eq!(buffer.get_text(), "hello");
buffer.set_selection(0, 5);
assert_eq!(buffer.get_selection_text(), "hello");
buffer.replace_selection("hi");
assert_eq!(buffer.get_text(), "hi");
assert_eq!(buffer.get_cursor_index(), 2);
assert!(buffer.delete_backward());
assert_eq!(buffer.get_text(), "h");생성.
Constructor.
반환ReturnsTextEditBuffer 빈 버퍼. (값과 조합 글이 비었고 최대 길이는 0)An empty buffer. (the value and composition are empty and the maximum length is 0)
값 설정. (max_length 로 자르고 커서는 끝에. 원본 setText)
Sets the value. (cut to max_length with the cursor at the end. The original setText)
- text&str
- 넣을 글. (되돌리기와 다시 하기 목록과 조합 중인 글도 비운다)Text to set. (also clears the undo and redo lists and the text being composed)
편집 시작 알리기. (고치기 전에 부른다. 새 묶음이면 지금 값을 되돌리기 목록에 쌓고 다시 하기 목록을 지운다)
Signals the start of an edit. (called before changing. if it is a new group, pushes the current value onto the undo list and clears the redo list)
- edit_kindTextEditKind
- 할 편집의 되돌리기 묶음 종류.Undo group kind of the edit to make.
열린 묶음 닫기. (다음 편집은 새 묶음)
Closes the open group. (the next edit is a new group)
되돌릴 것이 있는지.
Whether there is something to undo.
반환Returnsbool 되돌릴 묶음이 있으면 true.true if there is a group to undo.
다시 할 것이 있는지.
Whether there is something to redo.
반환Returnsbool 다시 할 묶음이 있으면 true.true if there is a group to redo.
되돌리기. (했으면 true)
Undoes. (true if done)
반환Returnsbool 되돌렸으면 true. 되돌릴 것이 없으면 false.true if undone. false if there is nothing to undo.
다시 하기. (했으면 true)
Redoes. (true if done)
반환Returnsbool 다시 했으면 true. 다시 할 것이 없으면 false.true if redone. false if there is nothing to redo.
값 반환.
Returns the value.
반환Returns&str 입력한 글. (조합 중인 글은 빠진다)The entered text. (text being composed is not included)
플랫폼이 준 값으로 바꾸기. (자르지 않는다. 커서를 정하고 선택은 접는다. 원본 handleDOMInputEvent)
Replaces with the value given by the platform. (not clamped. sets the cursor and collapses the selection. original handleDOMInputEvent)
- value&str
- 플랫폼 입력 칸의 값.The value of the platform input box.
- cursor_indexusize
- 커서 자리. (문자 단위, 값 끝을 넘으면 끝으로)Cursor position. (in characters, the end if past the end of the value)
최대 길이 설정. (UTF-16 단위, 0 이면 제한 없음. 원본처럼 지금 값은 자르지 않는다)
Sets the maximum length. (UTF-16 units, 0 for no limit. as in the original, the current value is not clamped)
- max_lengthusize
- 최대 글자 수. (UTF-16 단위, 0 이면 제한하지 않는다, 지금 값은 자르지 않는다)Maximum character count. (UTF-16 units, no limit if 0, the current value is not cut)
최대 길이 반환.
Returns the maximum length.
반환Returnsusize 최대 글자 수. (0 이면 제한하지 않는다)Maximum character count. (0 means no limit)
조합 글 설정.
Sets the composition text.
- composition&str
- IME 가 조합 중인 글. (빈 글이면 없음)Text being composed by the IME. (none if empty)
조합 글 반환.
Returns the composition text.
반환Returns&str IME 가 조합 중인 글. (없으면 빈 글)Text being composed by the IME. (empty if none)
커서 자리.
Cursor position.
반환Returnsusize 커서 자리. (문자 단위, 0 ~ 값의 문자 수)Cursor position. (in characters, 0 ~ the character count of the value)
선택 시작 자리. (선택을 늘릴 때 고정되는 쪽)
Selection start position. (the side that stays fixed when extending the selection)
반환Returnsusize 선택의 고정 끝. (문자 단위, 커서 자리와 같으면 선택이 없다)The fixed end of the selection. (in characters, no selection if equal to the cursor position)
선택 정하기. (끝을 넘으면 자른다)
Sets the selection. (clamped if past the end)
- selection_startusize
- 선택의 고정 끝. (문자 단위, 값 끝을 넘으면 끝으로)The fixed end of the selection. (in characters, the end if past the end of the value)
- cursor_indexusize
- 커서 자리. (문자 단위, 값 끝을 넘으면 끝으로)Cursor position. (in characters, the end if past the end of the value)
선택이 있는지.
Whether there is a selection.
반환Returnsbool 선택한 글이 있으면 참.True if text is selected.
선택 범위. (앞, 뒤. 없으면 None)
Selection range. (front, back. None if none)
반환ReturnsOption<(usize, usize)> 선택 범위 (앞, 뒤). (문자 단위, 앞이 작은 쪽, 선택이 없으면 None)Selection range (start, end). (in characters, start is the smaller one, None if there is no selection)
선택된 글.
Selected text.
반환ReturnsString 선택한 글. (없으면 빈 글)The selected text. (empty if none)
선택을 글로 바꾸기. (선택이 없으면 커서 자리에 끼운다. 원본 replaceSelection)
- max_length 가 있으면 블링크 입력 칸(text_field_input_type.cc 의 FilterBeforeTextInserted)처럼 넣는 글을 남은 UTF-16 길이까지만 넣는다. (글자는 쪼개지 않는다)
Replaces the selection with text. (inserted at the cursor if there is no selection. The original replaceSelection)
- With max_length, inserts text only up to the remaining UTF-16 length like a Blink input box (FilterBeforeTextInserted in text_field_input_type.cc). (characters are not split)
- text&str
- 넣을 글. (빈 글이면 선택을 지운다)Text to insert. (an empty string deletes the selection)
글자 하나 지우기. (그 자리부터 글자 묶음 하나, 크롬 Delete 키처럼 이모지나 결합 부호를 쪼개지 않는다. 원본 deleteCharAt)
Deletes one character. (one grapheme cluster from that position, does not split emoji or combining marks, like the Chrome Delete key. The original deleteCharAt)
- character_indexusize
- 지울 글자의 자리. (문자 단위)Index of the character to delete. (in characters)
글 범위 지우기. (문자 자리, 커서는 지운 자리로 당기고 선택은 접는다. 원본 deleteRange)
Deletes a text range. (character positions, the cursor is pulled to the deleted position and the selection collapses. The original deleteRange)
- start_indexusize
- 지울 범위의 앞. (문자 단위)Start of the range to delete. (in characters)
- end_indexusize
- 지울 범위의 뒤. (문자 단위, 앞보다 크지 않으면 아무것도 하지 않는다)End of the range to delete. (in characters, does nothing if it is not greater than the start)
뒤로 지우기. (선택이 있으면 선택을, 없으면 블링크 BackspaceStateMachine 이 정한 커서 앞 범위. 바뀌었으면 true)
Backspace. (the selection if there is one, otherwise the range before the cursor decided by Blink's BackspaceStateMachine. true if changed)
반환Returnsbool 지웠으면 true. 선택이 없고 커서가 글 앞이면 false.true if deleted. false if there is no selection and the cursor is at the start of the text.
앞으로 지우기. (선택이 있으면 선택을, 없으면 커서 뒤 글자 묶음. 바뀌었으면 true)
Forward delete. (the selection if there is one, otherwise the grapheme cluster after the cursor. true if changed)
반환Returnsbool 지웠으면 true. 선택이 없고 커서가 글 끝이면 false.true if deleted. false if there is no selection and the cursor is at the end of the text.
커서 옮기기. (글 안으로 자른다. 선택을 늘리지 않으면 선택을 접는다. 원본 moveCursor)
Moves the cursor. (clamped into the text. Collapses the selection unless extending it. The original moveCursor)
- new_indexusize
- 옮길 자리. (문자 단위, 0 ~ 값의 문자 수로 자른다)Index to move to. (in characters, clamped to 0 ~ the character count of the value)
- is_selection_extendedbool
- 참이면 선택의 고정 끝을 두고 선택을 늘린다.If true, keeps the fixed end of the selection and extends the selection.
모두 선택. (원본 selectAll)
Selects all. (the original selectAll)
커서 앞 글.
Text before the cursor.
반환Returns&str 값에서 커서 앞까지의 글.The text of the value up to the cursor.
조합 글이 들어갈 값의 자리. (조합 중이면 고른 글의 앞, 아니면 커서. 원본 #getCompositionStart)
- 고른 채 조합하면 확정이 고른 글을 갈음한다. 보이는 글은 [고른 글 앞, 조합 글, 고른 글 뒤] 다.
Position in the value where the composition goes. (the start of the selection while composing, otherwise the cursor. Original #getCompositionStart)
- When composing over a selection, committing replaces the selection. The shown text is [before the selection, the composition, after the selection].
반환Returnsusize 글자 자리.Character position.
조합 글이 갈음할 값의 끝. (조합 중이면 고른 글의 뒤, 아니면 커서. 원본 #getCompositionEnd)
End in the value that the composition replaces up to. (the end of the selection while composing, otherwise the cursor. Original #getCompositionEnd)
반환Returnsusize 글자 자리.Character position.
보이는 글의 커서 앞까지. (조합 중이면 조합 글이 들어갈 자리 앞의 값과 조합 글, 아니면 값의 커서 앞)
The shown text up to the cursor. (while composing, the value before where the composition goes plus the composition; otherwise the value before the cursor)
반환ReturnsString 보이는 글에서 커서 앞까지의 글.The shown text up to the cursor.
보이는 글. (커서 자리에 조합 글을 끼운 것, 고른 채 조합하면 고른 글 자리를 조합 글로 갈음한 것. 원본 getDisplayText)
Shown text. (the composition inserted at the cursor; when composing over a selection, the selection replaced by the composition. Original getDisplayText)
반환ReturnsString 보이는 글. (조합 중이 아니면 값 그대로)Shown text. (the value as is when not composing)
UIInputFieldstruct traits Default, Component, UIDocumentNode
입력 필드.
Input field.
use vanilla::{Engine, EngineConfiguration, NodeTree, TouchKind, UIInputField, Vector2};
let engine = Engine::new(EngineConfiguration::new());
let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let field_id = node_tree.create_child(root_id, "NameField");
node_tree[field_id].set_local_position(Vector2::create(100.0, 50.0));
node_tree[field_id].set_content_size(Vector2::create(300.0, 56.0));
let input_field = node_tree.add_component(field_id, UIInputField::new()).expect("input field");
input_field.set_use_dom_input(true);
input_field.set_placeholder("Name");
input_field.set_max_length(8);
input_field.set_text("Vanilla Engine");
assert_eq!(input_field.get_text(), "Vanilla ");
input_field.move_cursor(0, true);
assert_eq!(input_field.get_selection_range(), Some((0, 8)));
input_field.attach();
node_tree.dispatch_touch(field_id, &engine, TouchKind::Press, Vector2::create(150.0, 70.0));
assert!(node_tree[field_id].get_component::<UIInputField>().expect("input field").is_focused());생성. (기본값은 원본과 같다: 28px, 여백 16, 흰 바탕 둥글기 8, 글 #222222, 안내 글 #999999, 커서 #5b8def, 테두리 #f97316 3px)
Constructor. (defaults are the same as the original: 28px, padding 16, white background with rounding 8, text #222222, placeholder #999999, cursor #5b8def, border #f97316 3px)
반환ReturnsUIInputField 새 입력 필드. (값과 안내 글이 비었고 포커스가 없다)A new input field. (the value and placeholder are empty and it has no focus)
짝Counterpart: vanilla.js UIInputField.constructor
품은 컨트롤 반환.
Returns the embedded control.
반환Returns&UIControl 품은 UIControl.The embedded UIControl.
품은 컨트롤 반환. (변경용)
Returns the embedded control. (mutable)
반환Returns&mut UIControl 품은 UIControl.The embedded UIControl.
컨텐트 노드 핸들.
Content node handle.
반환ReturnsOption<NodeId> 호스트 노드 밑에 만든 컨텐트 노드. 트리에 붙기 전이면 None.Content node created under the host node. None before being attached to a tree.
필드 id. (엔진 글 입력 줄에서 이 필드를 가리키는 값)
Field id. (the value that refers to this field in the engine's text input line)
반환Returnsu64 필드 id. (1 부터)Field id. (from 1)
플랫폼 글 입력 사용 설정. (원본 setUseDOMInput. 켜야 한글 IME, 모바일 키보드, 웹 시스템 붙여넣기가 된다. 기본 꺼짐)
Sets whether to use platform text input. (original setUseDOMInput. must be on for Korean IME, mobile keyboards, and web system paste. off by default)
- use_dom_inputbool
- true 면 플랫폼 글 입력으로 받는다. (웹은 숨은 DOM 입력, 데스크탑은 IME)true to receive through platform text input. (hidden DOM input on the web, IME on desktop)
짝Counterpart: vanilla.js UIInputField.setUseDOMInput
플랫폼 글 입력 사용 여부.
Whether platform text input is used.
반환Returnsbool DOM 입력을 쓰면 참.True if the DOM input is used.
짝Counterpart: vanilla.js UIInputField.isUsingDOMInput
손을 뗄 때도 포커스를 줄지 설정. (웹 DOM 입력 전용. 첫 터치에 키보드를 띄우지 않는 브라우저용, 기본 꺼짐)
Sets whether to also give focus on release. (web DOM input only. for browsers that do not show the keyboard on the first touch, off by default)
- use_touch_end_focusbool
- 참이면 touchend 에서도 포커스를 준다. (기본 거짓)If true, also gives focus on touchend. (default false)
짝Counterpart: vanilla.js UIInputField.setUseTouchEndFocus
손을 뗄 때도 포커스를 주는지.
Whether focus is also given on release.
반환Returnsbool touchend 에서도 포커스를 주면 참.True if focus is also given on touchend.
짝Counterpart: vanilla.js UIInputField.isUsingTouchEndFocus
DOM 입력을 필드 위에서 직접 누르게 할지 설정. (use_dom_input 을 켠 필드에서 뜻이 있다, 기본 꺼짐)
- 웹: 원본처럼 투명한 DOM 입력이 필드 자리에서 누름을 받아, 브라우저 기본 동작으로 포커스와 키보드를 연다. (코드로 준 포커스를 받지 않는 웹뷰용) 그 필드의 오른쪽 단추는 원본처럼 브라우저 편집 칸 메뉴 대신 다른 필드와 같은 엔진 문맥 메뉴(잘라내기, 복사, 붙여넣기, 모두 선택)다. 손가락 길게 누르기는 크롬이 그 DOM 입력에 띄우는 것이다.
- 데스크탑: 원본에서 크롬이 그 DOM 입력에 하는 일을 엔진이 한다. 오른쪽 단추는 같은 엔진 문맥 메뉴이고, 손가락으로 650ms 길게 누르면(15 DIP 안) 낱말을 고르고 터치 손잡이와 빠른 메뉴를 띄운다. (크롬 데스크탑 터치, 윈도우는 뗄 때 메뉴를 정한다)
Sets whether the DOM input is pressed directly over the field. (meaningful for fields with use_dom_input on, off by default)
- Web: as in the original, a transparent DOM input receives presses at the field's position and opens focus and the keyboard through the browser's default behavior. (for webviews that do not accept focus given by code) The right button on that field opens the same engine context menu as other fields (cut, copy, paste, select all) instead of the browser edit-field menu, as in the original. The finger long press is what Chrome shows for that DOM input.
- Desktop: the engine does what Chrome does for that DOM input in the original. The right button opens the same engine context menu, and a 650ms finger long press (within 15 DIP) selects the word and shows touch handles and the quick menu. (Chrome desktop touch; Windows decides the menu on release)
- use_direct_touchbool
- 참이면 필드 자리의 누름을 DOM 입력이 직접 받는다. (데스크탑은 그 DOM 입력처럼 길게 누르기를 한다, 기본 거짓)If true, the DOM input receives presses at the field's position directly. (on desktop it does the long press like that DOM input, false by default)
짝Counterpart: vanilla.js UIInputField.setUseDirectTouch
DOM 입력을 직접 누르게 하는지.
Whether the DOM input is pressed directly.
반환Returnsbool DOM 입력이 누름을 직접 받으면 참.True if the DOM input takes presses directly.
짝Counterpart: vanilla.js UIInputField.isUsingDirectTouch
여러 줄 설정. (크롬 textarea 처럼. 웹 DOM 입력은 숨긴 <textarea> 를 쓴다. 원본 필드의 속성이 아니라 반사에서 뺀다)
Sets multiline. (like Chrome textarea. Web DOM input uses a hidden <textarea>. Not a property of the original field, so excluded from reflection)
- is_multilinebool
- true 면 여러 줄, false 면 한 줄. (처음 false, 바꾸면 스크롤을 처음으로)true for multiline, false for single line. (initially false, changing it resets the scroll)
짝Counterpart: vanilla.js UIInputField.setMultiline
여러 줄인지.
Whether it is multiline.
반환Returnsbool 여러 줄이면 true.true if multiline.
짝Counterpart: vanilla.js UIInputField.isMultiline
줄 높이 설정. (여러 줄 필드, None 이면 CSS normal 이다. 크롬 SimpleFontData 처럼 첫째 글꼴의 위아래 길이와 줄 사이를 반올림해 더한다)
Sets the line height. (multiline fields, CSS normal if None. Like Chrome SimpleFontData, adds the rounded ascent, descent and line gap of the first font)
- line_heightOption<f64>
- 줄 높이. (내용 크기 단위, None 이면 CSS normal)Line height. (content size units, CSS normal if None)
짝Counterpart: vanilla.js UIInputField.setLineHeight
줄 높이. (여러 줄 필드)
Line height. (multiline fields)
반환Returnsf64 줄 높이. (정하지 않았으면 CSS normal 로 잰 값, 글꼴을 하나도 읽지 못했으면 글꼴 크기의 1.2 배를 반올림한 값)Line height. (if not set, the value measured as CSS normal, or the font size times 1.2 rounded if no font could be read at all)
짝Counterpart: vanilla.js UIInputField.getLineHeight
탭 크기 설정. (여러 줄 필드, 공백 몇 개 폭. CSS tab-size, 기본 8)
Sets the tab size. (multiline fields, width in spaces. CSS tab-size, default 8)
- tab_sizef64
- 탭 크기. (공백 몇 개 폭, 음수는 0, 기본 8)Tab size. (width in spaces, negative becomes 0, default 8)
짝Counterpart: vanilla.js UIInputField.setTabSize
탭 크기.
Tab size.
반환Returnsf64 탭 크기. (공백 몇 개 폭)Tab size. (width in spaces)
짝Counterpart: vanilla.js UIInputField.getTabSize
위로 굴려 넘긴 만큼. (여러 줄 필드, 원본 textarea scrollTop)
Vertical scroll offset. (multiline fields, the original textarea scrollTop)
반환Returnsf64 위로 넘긴 만큼. (내용 크기 단위)The amount scrolled up. (content size units)
짝Counterpart: vanilla.js UIInputField.getScrollTop
위로 굴려 넘기기. (여러 줄 필드, 다음 그리기에서 글 끝 안으로 줄인다)
Sets the vertical scroll offset. (multiline fields, clamped to within the end of the text on the next draw)
- scroll_topf64
- 위로 넘길 만큼. (내용 크기 단위, 음수는 0)The amount to scroll up. (content size units, negative becomes 0)
짝Counterpart: vanilla.js UIInputField.setScrollTop
되돌릴 것이 있는지.
Whether there is something to undo.
반환Returnsbool 되돌릴 묶음이 있으면 true.true if there is a group to undo.
짝Counterpart: vanilla.js UIInputField.canUndo
다시 할 것이 있는지.
Whether there is something to redo.
반환Returnsbool 다시 할 묶음이 있으면 true.true if there is a group to redo.
짝Counterpart: vanilla.js UIInputField.canRedo
값 설정. (max_length 로 자르고 커서는 끝에. 바뀜 이벤트는 부르지 않는다. 원본 setText)
- 조합 중이었으면 조합을 버린다. (조합 글은 바꾸기 전 값에 끼운 것이다. 남겨 두면 확정이 오지 않을 때 조합 상태에 갇힌다)
Sets the value. (cut to max_length with the cursor at the end. Does not call the change event. The original setText)
- Drops the composition if composing. (the composition was inserted into the value before the change; if kept, the field stays composing when no commit comes)
- text&str
- 넣을 글. (되돌리기와 다시 하기 목록과 조합 중인 글도 비운다)Text to set. (also clears the undo and redo lists and the text being composed)
짝Counterpart: vanilla.js UIInputField.setText
값 반환.
Returns the value.
반환Returns&str 입력한 글. (조합 중인 글은 빠진다)The entered text. (text being composed is not included)
짝Counterpart: vanilla.js UIInputField.getText
보이는 글 반환. (값의 커서 자리에 조합 글을 끼운 것, 고른 채 조합하면 고른 글 자리를 조합 글로 갈음한 것. 원본 getDisplayText)
Returns the shown text. (the composition inserted at the cursor of the value; when composing over a selection, the selection replaced by the composition. Original getDisplayText)
반환ReturnsString 보이는 글. (조합 중이 아니면 값 그대로)Shown text. (the value as is when not composing)
짝Counterpart: vanilla.js UIInputField.getDisplayText
조합 중인 글 반환.
Returns the text being composed.
반환Returns&str IME 가 조합 중인 글. (없으면 빈 글)Text being composed by the IME. (empty if none)
짝Counterpart: vanilla.js UIInputField.getComposition
IME 조합 중인지.
Whether IME composition is in progress.
반환Returnsbool 조합 중이면 참.True while composing.
짝Counterpart: vanilla.js UIInputField.isComposing
안내 글 설정. (값이 비었을 때 보인다)
Sets the placeholder text. (shown when the value is empty)
- placeholder&str
- 값이 비었을 때 보일 글.Text shown when the value is empty.
짝Counterpart: vanilla.js UIInputField.setPlaceholder
안내 글 반환.
Returns the placeholder text.
반환Returns&str 플레이스홀더 글.Placeholder text.
짝Counterpart: vanilla.js UIInputField.getPlaceholder
최대 글자 수 설정. (원본처럼 UTF-16 단위, 0 이면 제한 없음)
Sets the maximum character count. (UTF-16 units as in the original, 0 for no limit)
- max_lengthusize
- 최대 글자 수. (UTF-16 단위, 0 이면 제한하지 않는다, 지금 값은 자르지 않는다)Maximum character count. (UTF-16 units, no limit if 0, the current value is not cut)
짝Counterpart: vanilla.js UIInputField.setMaxLength
최대 글자 수 반환.
Returns the maximum character count.
반환Returnsusize 최대 글자 수. (0 이면 제한하지 않는다)Maximum character count. (0 means no limit)
짝Counterpart: vanilla.js UIInputField.getMaxLength
글자 크기 설정.
Sets the font size.
- font_sizef64
- 글자 크기. (내용 크기 단위, 기본 28)Font size. (content size units, default 28)
짝Counterpart: vanilla.js UIInputField.setFontSize
글자 크기 반환.
Returns the font size.
반환Returnsf64 글자 크기.Font size.
짝Counterpart: vanilla.js UIInputField.getFontSize
폰트 이름 설정. (원본 setFont 자리. Graphic 에 등록한 이름, 없으면 기본 폰트)
Sets the font name. (in place of the original setFont. a name registered with Graphic, the default font if none)
- font_family&str
- Graphic 에 등록한 폰트 이름. (처음 "default", 엔진 기본 폰트)Font name registered with Graphic. (initially "default", the engine default font)
폰트 이름 반환.
Returns the font name.
반환Returns&str 폰트 이름. (처음 "default")Font name. (initially "default")
안쪽 여백 설정. (글 왼쪽 여백)
Sets the inner padding. (left padding of the text)
- paddingf64
- 왼쪽과 오른쪽 안쪽 여백. (내용 크기 단위, 기본 16, 여러 줄 필드는 위아래에도)Left and right inner padding. (content size units, default 16, also top and bottom for multiline fields)
짝Counterpart: vanilla.js UIInputField.setPadding
안쪽 여백 반환.
Returns the inner padding.
반환Returnsf64 왼쪽과 오른쪽 안쪽 여백.Left and right inner padding.
짝Counterpart: vanilla.js UIInputField.getPadding
바탕색 설정.
Sets the background color.
- colorimpl Into<Color>
- 배경색. (기본 흰색)Background color. (default white)
짝Counterpart: vanilla.js UIInputField.setBackgroundColor
바탕색 반환.
Returns the background color.
반환ReturnsColor 배경색.Background color.
짝Counterpart: vanilla.js UIInputField.getBackgroundColor
바탕 둥글기 설정. (포커스 테두리도 따른다)
Sets the background rounding. (the focus border follows it)
- round_sizef64
- 배경과 포커스 테두리의 모서리 반지름. (기본 8)Corner radius of the background and the focus border. (default 8)
짝Counterpart: vanilla.js UIInputField.setRoundSize
바탕 둥글기 반환.
Returns the background rounding.
반환Returnsf64 배경의 모서리 반지름.Corner radius of the background.
짝Counterpart: vanilla.js UIInputField.getRoundSize
글자 색 설정.
Sets the text color.
- colorimpl Into<Color>
- 값 글자의 색. (기본 #222222)Color of the value text. (default #222222)
짝Counterpart: vanilla.js UIInputField.setTextColor
글자 색 반환.
Returns the text color.
반환ReturnsColor 값 글자의 색.Color of the value text.
짝Counterpart: vanilla.js UIInputField.getTextColor
안내 글 색 설정.
Sets the placeholder text color.
- colorimpl Into<Color>
- 플레이스홀더 글자의 색. (기본 #999999)Color of the placeholder text. (default #999999)
짝Counterpart: vanilla.js UIInputField.setPlaceholderColor
안내 글 색 반환.
Returns the placeholder text color.
반환ReturnsColor 플레이스홀더 글자의 색.Color of the placeholder text.
짝Counterpart: vanilla.js UIInputField.getPlaceholderColor
커서 색 설정. (조합 밑줄도 같은 색. 원본과 같음)
Sets the cursor color. (the composition underline uses the same color. same as the original)
- colorimpl Into<Color>
- 커서와 조합 밑줄의 색. (기본 #5b8def)Color of the cursor and the composition underline. (default #5b8def)
짝Counterpart: vanilla.js UIInputField.setCursorColor
커서 색 반환.
Returns the cursor color.
반환ReturnsColor 커서 색.Cursor color.
짝Counterpart: vanilla.js UIInputField.getCursorColor
포커스 테두리 색 설정.
Sets the focus border color.
- colorimpl Into<Color>
- 포커스 테두리 색. (기본 #f97316)Focus border color. (default #f97316)
짝Counterpart: vanilla.js UIInputField.setFocusBorderColor
포커스 테두리 두께 설정. (0 이면 그리지 않는다)
Sets the focus border thickness. (not drawn if 0)
- focus_border_widthf64
- 포커스 테두리 두께. (0 이하면 그리지 않는다, 기본 3)Focus border width. (not drawn if 0 or less, default 3)
짝Counterpart: vanilla.js UIInputField.setFocusBorderWidth
선택 영역 색 설정.
Sets the selection color.
- colorimpl Into<Color>
- 선택 영역을 칠할 색. (기본 알파 0.35 의 파랑)Color to fill the selection with. (default blue with alpha 0.35)
짝Counterpart: vanilla.js UIInputField.setSelectionColor
바뀜 이벤트 설정. (사용자 입력으로 값이 바뀔 때. 원본 setOnChange)
Sets the change event. (when user input changes the value. The original setOnChange)
- change_eventUIInputFieldEvent
- 사용자 입력으로 값이 바뀔 때마다 부를 함수. (필드와 문맥을 받는다, 값은
field.get_text(), set_text 로 바꿀 때는 부르지 않는다)Function called whenever user input changes the value. (takes the field and the context, the value isfield.get_text(), not called when changed with set_text)
짝Counterpart: vanilla.js UIInputField.setOnChange
제출 이벤트 설정. (Enter. 원본 setOnSubmit)
Sets the submit event. (Enter. The original setOnSubmit)
- submit_eventUIInputFieldEvent
- 포커스된 채 Enter 를 누르면 부를 함수. (한 줄 필드만, 필드와 문맥을 받는다, 값은
field.get_text())Function called when Enter is pressed while focused. (single-line fields only, takes the field and the context, the value isfield.get_text())
짝Counterpart: vanilla.js UIInputField.setOnSubmit
입력 받기 시작. (원본 attach: DOM 입력 또는 캔버스 키보드, 문맥 메뉴)
Starts taking input. (original attach: DOM input or canvas keyboard, context menu)
짝Counterpart: vanilla.js UIInputField.attach
입력 받기 끝. (원본 detach. DOM 입력을 쓰던 필드는 포커스와 조합 글도 잃는다)
Stops taking input. (original detach. a field that was using DOM input also loses focus and the composition text)
짝Counterpart: vanilla.js UIInputField.detach
입력을 받기로 했는지.
Whether it has started taking input.
반환Returnsbool attach 뒤 detach 전이면 true.true after attach and before detach.
포커스 주기. (원본 focus. 플랫폼 입력은 다음 프레임에 이 필드로 온다)
Gives focus. (original focus. platform input comes to this field from the next frame)
짝Counterpart: vanilla.js UIInputField.focus
포커스 빼기. (원본 blur. 조합 중이던 글은 확정한다. 씬 코드에서 부르면 바뀜 이벤트는 부르지 않는다)
Removes focus. (original blur. commits any text being composed. when called from scene code, the changed event is not called)
짝Counterpart: vanilla.js UIInputField.blur
포커스를 가졌는지.
Whether it has focus.
반환Returnsbool 포커스를 가졌으면 참.True if it has focus.
짝Counterpart: vanilla.js UIInputField.isFocused
모두 선택.
Selects all.
짝Counterpart: vanilla.js UIInputField.selectAll
선택이 있는지.
Whether there is a selection.
반환Returnsbool 선택한 글이 있으면 참.True if text is selected.
짝Counterpart: vanilla.js UIInputField.hasSelection
선택 범위. (앞, 뒤. 원본처럼 UTF-16 단위, 없으면 None)
Selection range. (front, back. UTF-16 units as in the original, None if none)
반환ReturnsOption<(usize, usize)> 선택 범위 (앞, 뒤). (UTF-16 단위, 앞이 작은 쪽, 선택이 없으면 None)Selection range (start, end). (UTF-16 units, start is the smaller one, None if there is no selection)
짝Counterpart: vanilla.js UIInputField.getSelectionRange
선택된 글.
Selected text.
반환ReturnsString 선택한 글. (없으면 빈 글)The selected text. (empty if none)
짝Counterpart: vanilla.js UIInputField.getSelectionText
커서 자리. (원본처럼 UTF-16 단위)
Cursor position. (UTF-16 units as in the original)
반환Returnsusize 커서 자리. (값 안의 글자 위치, 0 ~ 값 길이)Cursor position. (character position in the value, 0 ~ value length)
짝Counterpart: vanilla.js UIInputField.getCursorIndex
선택 시작 자리. (원본처럼 UTF-16 단위)
Selection start position. (UTF-16 units as in the original)
반환Returnsusize 선택의 고정 끝. (커서 자리와 같으면 선택이 없다)The fixed end of the selection. (no selection if equal to the cursor position)
짝Counterpart: vanilla.js UIInputField.getSelectionStart
커서 옮기기. (원본 moveCursor, 자리는 UTF-16 단위)
Moves the cursor. (the original moveCursor, positions in UTF-16 units)
- new_indexusize
- 옮길 자리. (UTF-16 단위, 0 ~ 값 길이로 자른다, 서로게이트 쌍 가운데면 그 글자 뒤로 본다)Index to move to. (UTF-16 units, clamped to 0 to the value length, an index inside a surrogate pair is taken as after that character)
- is_selection_extendedbool
- 참이면 선택의 고정 끝을 두고 선택을 늘린다.If true, keeps the fixed end of the selection and extends the selection.
짝Counterpart: vanilla.js UIInputField.moveCursor
선택을 글로 바꾸고 바뀜 이벤트 부르기. (원본 replaceSelection)
Replaces the selection with text and calls the change event. (the original replaceSelection)
- context&mut ComponentContext
- 바뀜 이벤트에 넘길 컴포넌트 문맥.Component context to pass to the change event.
- text&str
- 넣을 글. (빈 글이면 선택을 지운다)Text to insert. (an empty string deletes the selection)
짝Counterpart: vanilla.js UIInputField.replaceSelection
잘라내기. (선택을 클립보드에 쓰고 지운다)
Cuts. (writes the selection to the clipboard and deletes it)
- context&mut ComponentContext
- 클립보드를 쓸 엔진과 바뀜 이벤트에 넘길 컴포넌트 문맥.Component context that provides the engine for writing the clipboard and is passed to the change event.
짝Counterpart: vanilla.js UIInputField.cut
복사. (선택을 클립보드에 쓴다)
Copies. (writes the selection to the clipboard)
- engine&Engine
- 클립보드를 쓸 엔진.Engine to write the clipboard with.
짝Counterpart: vanilla.js UIInputField.copy
붙여넣기. (데스크탑은 클립보드를 그 자리에서 읽는다. 웹은 원본처럼 비동기로 읽고, 다 읽으면 이 필드의 글 입력 줄로 넣어 다음 tick 에 붙인다)
Pastes. (desktop reads the clipboard on the spot. the web reads it asynchronously as in the original, and once read, puts it into this field's text input line and pastes it on the next tick)
- context&mut ComponentContext
- 클립보드를 읽을 엔진과 바뀜 이벤트에 넘길 컴포넌트 문맥. (웹은 쓰지 않는다)Component context that provides the engine for reading the clipboard and is passed to the change event. (unused on the web)
짝Counterpart: vanilla.js UIInputField.paste
노드 x(content 영역 기준) → 글자 자리. (원본처럼 UTF-16 단위)
Node x (relative to the content area) → character position. (UTF-16 units as in the original)
- local_xf64
- 노드 안의 X. (내용 영역 왼쪽이 0)X inside the node. (0 at the left of the content area)
반환Returnsusize 그 자리에 가장 가까운 글자 묶음 경계. (UTF-16 단위, 0 ~ 값 길이, 아직 그려 재지 않았으면 값 길이)The grapheme cluster boundary nearest to that point. (UTF-16 units, 0 to the value length, the value length if not yet measured by drawing)
짝Counterpart: vanilla.js UIInputField.measureIndexAtLocalX
함수Functions
글자 경계 x 목록에서 누른 x 에 가까운 글자 자리 찾기. (원본 measureIndexAtLocalX 의 비교)
character_offsets[i]는 앞 i 글자의 폭이다. (0 번은 0)
Finds the character position closest to the pressed x from a list of character boundary x values. (the comparison in the original measureIndexAtLocalX)
character_offsets[i]is the width of the first i characters. (0 for index 0)
- character_offsets&[f64]
- 앞 i 글자의 폭 목록. (0 번은 0, 글자 수 + 1 개)List of widths of the first i characters. (0 for index 0, character count + 1 entries)
- target_xf64
- 누른 x. (첫 글자 왼쪽이 0)Pressed x. (0 at the left of the first character)
반환Returnsusize 가장 가까운 글자 경계의 자리. (0 ~ 글자 수)Position of the nearest character boundary. (0 ~ character count)
UIInputFieldMenuActionenum traits Clone, Copy, Debug, PartialEq, Eq
문맥 메뉴 항목. (원본 UIInputFieldMenuAction 의 잘라내기 / 복사 / 붙여넣기 / 모두 선택, request_menu_action 이 받는다)
Context menu item. (cut / copy / paste / select all of the original UIInputFieldMenuAction, received by request_menu_action)
| 이름Name | 설명Description |
|---|---|
Cut | 잘라내기.Cut. |
Copy | 복사.Copy. |
Paste | 붙여넣기.Paste. |
SelectAll | 모두 선택.Selects all. |
TextEditKindenum traits Clone, Copy, Debug, PartialEq, Eq
되돌리기 묶음 종류. (블링크 TypingCommand 와 붙여넣기)
Undo group kind. (Blink TypingCommand and paste)
| 이름Name | 설명Description |
|---|---|
InsertText | 글자 넣기. (열린 묶음이 있으면 종류를 가리지 않고 그 묶음에 붙고, 묶음은 글자 넣기가 된다)Insert text. (joins the open group regardless of its kind if there is one, and the group becomes insert text) |
DeleteBackward | 뒤로 지우기. (열린 묶음이 뒤로 지우기일 때만 붙고, 아니면 새 묶음)Delete backward. (joins only if the open group is delete backward, otherwise a new group) |
DeleteForward | 앞으로 지우기. (열린 묶음이 앞으로 지우기일 때만 붙고, 아니면 새 묶음)Delete forward. (joins only if the open group is delete forward, otherwise a new group) |
Paste | 붙여넣기와 잘라내기, 낱말 지우기 키로 고른 것 지우기. (블링크 ReplaceSelectionCommand, DeleteSelectionCommand 라 늘 따로 한 묶음이고, 그 뒤 글자 넣기도 새 묶음)Paste, cut, and deleting a selection with the word deletion keys. (Blink ReplaceSelectionCommand, DeleteSelectionCommand, so always a separate group, and character insertion after it is a new group too) |
DeleteWordBackward | 낱말 뒤로 지우기. (블링크는 늘 새 TypingCommand 를 열어 새 묶음이고, 그 뒤 뒤로 지우기와 글자 넣기는 이 묶음에 붙는다)Delete word backward. (Blink always opens a new TypingCommand, so it is a new group, and Backspace and character insertion after it join this group) |
DeleteWordForward | 낱말 앞으로 지우기. (늘 새 묶음이고, 그 뒤 앞으로 지우기와 글자 넣기는 이 묶음에 붙는다)Delete word forward. (always a new group, and forward delete and character insertion after it join this group) |