diff options
Diffstat (limited to 'doc/classes/LineEdit.xml')
-rw-r--r-- | doc/classes/LineEdit.xml | 89 |
1 files changed, 67 insertions, 22 deletions
diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index b8383aaed9..8ed8622030 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -61,6 +61,45 @@ <return type="PopupMenu" /> <description> Returns the [PopupMenu] of this [LineEdit]. By default, this menu is displayed when right-clicking on the [LineEdit]. + You can add custom menu items or remove standard ones. Make sure your IDs don't conflict with the standard ones (see [enum MenuItems]). For example: + [codeblocks] + [gdscript] + func _ready(): + var menu = get_menu() + # Remove all items after "Redo". + menu.item_count = menu.get_item_index(MENU_REDO) + 1 + # Add custom items. + menu.add_separator() + menu.add_item("Insert Date", MENU_MAX + 1) + # Connect callback. + menu.id_pressed.connect(_on_item_pressed) + + func _on_item_pressed(id): + if id == MENU_MAX + 1: + insert_text_at_caret(Time.get_date_string_from_system()) + [/gdscript] + [csharp] + public override void _Ready() + { + var menu = GetMenu(); + // Remove all items after "Redo". + menu.ItemCount = menu.GetItemIndex(LineEdit.MenuItems.Redo) + 1; + // Add custom items. + menu.AddSeparator(); + menu.AddItem("Insert Date", LineEdit.MenuItems.Max + 1); + // Add event handler. + menu.IdPressed += OnItemPressed; + } + + public void OnItemPressed(int id) + { + if (id == LineEdit.MenuItems.Max + 1) + { + InsertTextAtCaret(Time.GetDateStringFromSystem()); + } + } + [/csharp] + [/codeblocks] [b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their [member Window.visible] property. </description> </method> @@ -296,70 +335,76 @@ <constant name="MENU_REDO" value="6" enum="MenuItems"> Reverse the last undo action. </constant> - <constant name="MENU_DIR_INHERITED" value="7" enum="MenuItems"> + <constant name="MENU_SUBMENU_TEXT_DIR" value="7" enum="MenuItems"> + ID of "Text Writing Direction" submenu. + </constant> + <constant name="MENU_DIR_INHERITED" value="8" enum="MenuItems"> Sets text direction to inherited. </constant> - <constant name="MENU_DIR_AUTO" value="8" enum="MenuItems"> + <constant name="MENU_DIR_AUTO" value="9" enum="MenuItems"> Sets text direction to automatic. </constant> - <constant name="MENU_DIR_LTR" value="9" enum="MenuItems"> + <constant name="MENU_DIR_LTR" value="10" enum="MenuItems"> Sets text direction to left-to-right. </constant> - <constant name="MENU_DIR_RTL" value="10" enum="MenuItems"> + <constant name="MENU_DIR_RTL" value="11" enum="MenuItems"> Sets text direction to right-to-left. </constant> - <constant name="MENU_DISPLAY_UCC" value="11" enum="MenuItems"> + <constant name="MENU_DISPLAY_UCC" value="12" enum="MenuItems"> Toggles control character display. </constant> - <constant name="MENU_INSERT_LRM" value="12" enum="MenuItems"> + <constant name="MENU_SUBMENU_INSERT_UCC" value="13" enum="MenuItems"> + ID of "Insert Control Character" submenu. + </constant> + <constant name="MENU_INSERT_LRM" value="14" enum="MenuItems"> Inserts left-to-right mark (LRM) character. </constant> - <constant name="MENU_INSERT_RLM" value="13" enum="MenuItems"> + <constant name="MENU_INSERT_RLM" value="15" enum="MenuItems"> Inserts right-to-left mark (RLM) character. </constant> - <constant name="MENU_INSERT_LRE" value="14" enum="MenuItems"> + <constant name="MENU_INSERT_LRE" value="16" enum="MenuItems"> Inserts start of left-to-right embedding (LRE) character. </constant> - <constant name="MENU_INSERT_RLE" value="15" enum="MenuItems"> + <constant name="MENU_INSERT_RLE" value="17" enum="MenuItems"> Inserts start of right-to-left embedding (RLE) character. </constant> - <constant name="MENU_INSERT_LRO" value="16" enum="MenuItems"> + <constant name="MENU_INSERT_LRO" value="18" enum="MenuItems"> Inserts start of left-to-right override (LRO) character. </constant> - <constant name="MENU_INSERT_RLO" value="17" enum="MenuItems"> + <constant name="MENU_INSERT_RLO" value="19" enum="MenuItems"> Inserts start of right-to-left override (RLO) character. </constant> - <constant name="MENU_INSERT_PDF" value="18" enum="MenuItems"> + <constant name="MENU_INSERT_PDF" value="20" enum="MenuItems"> Inserts pop direction formatting (PDF) character. </constant> - <constant name="MENU_INSERT_ALM" value="19" enum="MenuItems"> + <constant name="MENU_INSERT_ALM" value="21" enum="MenuItems"> Inserts Arabic letter mark (ALM) character. </constant> - <constant name="MENU_INSERT_LRI" value="20" enum="MenuItems"> + <constant name="MENU_INSERT_LRI" value="22" enum="MenuItems"> Inserts left-to-right isolate (LRI) character. </constant> - <constant name="MENU_INSERT_RLI" value="21" enum="MenuItems"> + <constant name="MENU_INSERT_RLI" value="23" enum="MenuItems"> Inserts right-to-left isolate (RLI) character. </constant> - <constant name="MENU_INSERT_FSI" value="22" enum="MenuItems"> + <constant name="MENU_INSERT_FSI" value="24" enum="MenuItems"> Inserts first strong isolate (FSI) character. </constant> - <constant name="MENU_INSERT_PDI" value="23" enum="MenuItems"> + <constant name="MENU_INSERT_PDI" value="25" enum="MenuItems"> Inserts pop direction isolate (PDI) character. </constant> - <constant name="MENU_INSERT_ZWJ" value="24" enum="MenuItems"> + <constant name="MENU_INSERT_ZWJ" value="26" enum="MenuItems"> Inserts zero width joiner (ZWJ) character. </constant> - <constant name="MENU_INSERT_ZWNJ" value="25" enum="MenuItems"> + <constant name="MENU_INSERT_ZWNJ" value="27" enum="MenuItems"> Inserts zero width non-joiner (ZWNJ) character. </constant> - <constant name="MENU_INSERT_WJ" value="26" enum="MenuItems"> + <constant name="MENU_INSERT_WJ" value="28" enum="MenuItems"> Inserts word joiner (WJ) character. </constant> - <constant name="MENU_INSERT_SHY" value="27" enum="MenuItems"> + <constant name="MENU_INSERT_SHY" value="29" enum="MenuItems"> Inserts soft hyphen (SHY) character. </constant> - <constant name="MENU_MAX" value="28" enum="MenuItems"> + <constant name="MENU_MAX" value="30" enum="MenuItems"> Represents the size of the [enum MenuItems] enum. </constant> <constant name="KEYBOARD_TYPE_DEFAULT" value="0" enum="VirtualKeyboardType"> |