Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
TextEdit¶
继承: Control < CanvasItem < Node < Object
派生: CodeEdit
多行文本编辑器。
描述¶
多行文本编辑器。它还有少量用于编辑代码的功能,例如语法高亮支持。更多针对编辑代码的高阶功能见 CodeEdit。
注意:大多数视口、光标和编辑方法都包含 caret_index
参数以支持 caret_multiple。该参数应为以下之一:-1
用于所有光标,0
用于主光标,大于 0
用于辅助光标。
注意:当按住 Alt 时,垂直滚轮的滚动速度将是正常速度的 5 倍。这也适用于 Godot 脚本编辑器。
属性¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
focus_mode |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
mouse_default_cursor_shape |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法¶
void |
_backspace ( int caret_index ) virtual |
void |
|
void |
|
void |
_handle_unicode_input ( int unicode_char, int caret_index ) virtual |
void |
|
void |
_paste_primary_clipboard ( int caret_index ) virtual |
void |
add_caret_at_carets ( bool below ) |
void |
add_gutter ( int at=-1 ) |
void |
|
void |
adjust_carets_after_edit ( int caret, int from_line, int from_col, int to_line, int to_col ) |
void |
adjust_viewport_to_caret ( int caret_index=0 ) |
void |
|
void |
|
void |
center_viewport_to_caret ( int caret_index=0 ) |
void |
clear ( ) |
void |
|
void |
|
void |
|
void |
delete_selection ( int caret_index=-1 ) |
void |
|
void |
end_action ( ) |
void |
|
get_caret_column ( int caret_index=0 ) const |
|
get_caret_count ( ) const |
|
get_caret_draw_pos ( int caret_index=0 ) const |
|
get_caret_line ( int caret_index=0 ) const |
|
get_caret_wrap_index ( int caret_index=0 ) const |
|
get_first_non_whitespace_column ( int line ) const |
|
get_first_visible_line ( ) const |
|
get_gutter_count ( ) const |
|
get_gutter_name ( int gutter ) const |
|
get_gutter_type ( int gutter ) const |
|
get_gutter_width ( int gutter ) const |
|
get_h_scroll_bar ( ) const |
|
get_indent_level ( int line ) const |
|
get_last_full_visible_line ( ) const |
|
get_last_full_visible_line_wrap_index ( ) const |
|
get_last_unhidden_line ( ) const |
|
get_line_background_color ( int line ) const |
|
get_line_column_at_pos ( Vector2i position, bool allow_out_of_bounds=true ) const |
|
get_line_count ( ) const |
|
get_line_gutter_icon ( int line, int gutter ) const |
|
get_line_gutter_item_color ( int line, int gutter ) const |
|
get_line_gutter_metadata ( int line, int gutter ) const |
|
get_line_gutter_text ( int line, int gutter ) const |
|
get_line_height ( ) const |
|
get_line_width ( int line, int wrap_index=-1 ) const |
|
get_line_wrap_count ( int line ) const |
|
get_line_wrap_index_at_column ( int line, int column ) const |
|
get_line_wrapped_text ( int line ) const |
|
get_local_mouse_pos ( ) const |
|
get_menu ( ) const |
|
get_minimap_line_at_pos ( Vector2i position ) const |
|
get_minimap_visible_lines ( ) const |
|
get_next_visible_line_index_offset_from ( int line, int wrap_index, int visible_amount ) const |
|
get_next_visible_line_offset_from ( int line, int visible_amount ) const |
|
get_pos_at_line_column ( int line, int column ) const |
|
get_rect_at_line_column ( int line, int column ) const |
|
get_saved_version ( ) const |
|
get_scroll_pos_for_line ( int line, int wrap_index=0 ) const |
|
get_selected_text ( int caret_index=-1 ) |
|
get_selection_column ( int caret_index=0 ) const |
|
get_selection_from_column ( int caret_index=0 ) const |
|
get_selection_from_line ( int caret_index=0 ) const |
|
get_selection_line ( int caret_index=0 ) const |
|
get_selection_mode ( ) const |
|
get_selection_to_column ( int caret_index=0 ) const |
|
get_selection_to_line ( int caret_index=0 ) const |
|
get_tab_size ( ) const |
|
get_total_gutter_width ( ) const |
|
get_total_visible_line_count ( ) const |
|
get_v_scroll_bar ( ) const |
|
get_version ( ) const |
|
get_visible_line_count ( ) const |
|
get_visible_line_count_in_range ( int from_line, int to_line ) const |
|
get_word_at_pos ( Vector2 position ) const |
|
get_word_under_caret ( int caret_index=-1 ) const |
|
has_ime_text ( ) const |
|
has_redo ( ) const |
|
has_selection ( int caret_index=-1 ) const |
|
has_undo ( ) const |
|
void |
insert_line_at ( int line, String text ) |
void |
insert_text_at_caret ( String text, int caret_index=-1 ) |
is_caret_visible ( int caret_index=0 ) const |
|
is_dragging_cursor ( ) const |
|
is_gutter_clickable ( int gutter ) const |
|
is_gutter_drawn ( int gutter ) const |
|
is_gutter_overwritable ( int gutter ) const |
|
is_line_gutter_clickable ( int line, int gutter ) const |
|
is_line_wrapped ( int line ) const |
|
is_menu_visible ( ) const |
|
is_mouse_over_selection ( bool edges, int caret_index=-1 ) const |
|
is_overtype_mode_enabled ( ) const |
|
void |
menu_option ( int option ) |
void |
merge_gutters ( int from_line, int to_line ) |
void |
|
void |
|
void |
paste_primary_clipboard ( int caret_index=-1 ) |
void |
redo ( ) |
void |
remove_caret ( int caret ) |
void |
remove_gutter ( int gutter ) |
void |
|
void |
remove_text ( int from_line, int from_column, int to_line, int to_column ) |
search ( String text, int flags, int from_line, int from_colum ) const |
|
void |
select ( int from_line, int from_column, int to_line, int to_column, int caret_index=0 ) |
void |
select_all ( ) |
void |
select_word_under_caret ( int caret_index=-1 ) |
void |
set_caret_column ( int column, bool adjust_viewport=true, int caret_index=0 ) |
void |
set_caret_line ( int line, bool adjust_viewport=true, bool can_be_hidden=true, int wrap_index=0, int caret_index=0 ) |
void |
set_gutter_clickable ( int gutter, bool clickable ) |
void |
set_gutter_custom_draw ( int column, Callable draw_callback ) |
void |
set_gutter_draw ( int gutter, bool draw ) |
void |
set_gutter_name ( int gutter, String name ) |
void |
set_gutter_overwritable ( int gutter, bool overwritable ) |
void |
set_gutter_type ( int gutter, GutterType type ) |
void |
set_gutter_width ( int gutter, int width ) |
void |
|
void |
set_line_as_center_visible ( int line, int wrap_index=0 ) |
void |
set_line_as_first_visible ( int line, int wrap_index=0 ) |
void |
set_line_as_last_visible ( int line, int wrap_index=0 ) |
void |
set_line_background_color ( int line, Color color ) |
void |
set_line_gutter_clickable ( int line, int gutter, bool clickable ) |
void |
set_line_gutter_icon ( int line, int gutter, Texture2D icon ) |
void |
set_line_gutter_item_color ( int line, int gutter, Color color ) |
void |
set_line_gutter_metadata ( int line, int gutter, Variant metadata ) |
void |
set_line_gutter_text ( int line, int gutter, String text ) |
void |
set_overtype_mode_enabled ( bool enabled ) |
void |
set_search_flags ( int flags ) |
void |
set_search_text ( String search_text ) |
void |
set_selection_mode ( SelectionMode mode, int line=-1, int column=-1, int caret_index=0 ) |
void |
set_tab_size ( int size ) |
void |
set_tooltip_request_func ( Callable callback ) |
void |
start_action ( EditAction action ) |
void |
swap_lines ( int from_line, int to_line ) |
void |
|
void |
undo ( ) |
主题属性¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
信号¶
caret_changed ( )
光标改变位置时发出。
gutter_added ( )
添加边栏时发出。
gutter_clicked ( int line, int gutter )
点击边栏时发出。
gutter_removed ( )
移除边栏时发出。
lines_edited_from ( int from_line, int to_line )
文本改变时立即发出。
添加文本时 from_line
小于 to_line
。移除文本时 to_line
小于 from_line
。
text_changed ( )
当文本更改时触发。
text_set ( )
枚举¶
剪切(复制并删除)选中的文本。
复制选中的文本。
将剪贴板上的文本粘贴在选定的文本上(或光标的位置)。
擦除整个 TextEdit 文本。
选择整个 TextEdit 文本。
撤销之前的操作。
重做前一个动作。
“文本书写方向”子菜单的 ID。
将文本方向设置为继承。
将文本方向设置为自动。
将文本方向设置为从左至右。
将文本方向设置为从右至左。
切换控制字符的显示。
“插入控制字符”子菜单的 ID。
插入从左至右标志(LRM)字符。
插入从右至左标志(LRM)字符。
插入开始从左至右嵌入(LRE)字符。
插入开始从右至左嵌入(RLE)字符。
插入开始从左至右强制(LRO)字符。