1 /** 2 Control that provides single-line string editing. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.lineedit; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.control; 25 import godot.canvasitem; 26 import godot.node; 27 import godot.inputevent; 28 import godot.popupmenu; 29 import godot.texture; 30 /** 31 Control that provides single-line string editing. 32 33 LineEdit provides a single-line string editor, used for text fields. 34 It features many built-in shortcuts which will always be available (`Ctrl` here maps to `Command` on macOS): 35 - Ctrl + C: Copy 36 - Ctrl + X: Cut 37 - Ctrl + V or Ctrl + Y: Paste/"yank" 38 - Ctrl + Z: Undo 39 - Ctrl + Shift + Z: Redo 40 - Ctrl + U: Delete text from the cursor position to the beginning of the line 41 - Ctrl + K: Delete text from the cursor position to the end of the line 42 - Ctrl + A: Select all text 43 - Up/Down arrow: Move the cursor to the beginning/end of the line 44 On macOS, some extra keyboard shortcuts are available: 45 - Ctrl + F: Like the right arrow key, move the cursor one character right 46 - Ctrl + B: Like the left arrow key, move the cursor one character left 47 - Ctrl + P: Like the up arrow key, move the cursor to the previous line 48 - Ctrl + N: Like the down arrow key, move the cursor to the next line 49 - Ctrl + D: Like the Delete key, delete the character on the right side of cursor 50 - Ctrl + H: Like the Backspace key, delete the character on the left side of the cursor 51 - Command + Left arrow: Like the Home key, move the cursor to the beginning of the line 52 - Command + Right arrow: Like the End key, move the cursor to the end of the line 53 */ 54 @GodotBaseClass struct LineEdit 55 { 56 package(godot) enum string _GODOT_internal_name = "LineEdit"; 57 public: 58 @nogc nothrow: 59 union { /** */ godot_object _godot_object; /** */ Control _GODOT_base; } 60 alias _GODOT_base this; 61 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 62 package(godot) __gshared bool _classBindingInitialized = false; 63 package(godot) static struct GDNativeClassBinding 64 { 65 __gshared: 66 @GodotName("_editor_settings_changed") GodotMethod!(void) _editorSettingsChanged; 67 @GodotName("_gui_input") GodotMethod!(void, InputEvent) _guiInput; 68 @GodotName("_text_changed") GodotMethod!(void) _textChanged; 69 @GodotName("_toggle_draw_caret") GodotMethod!(void) _toggleDrawCaret; 70 @GodotName("append_at_cursor") GodotMethod!(void, String) appendAtCursor; 71 @GodotName("clear") GodotMethod!(void) clear; 72 @GodotName("cursor_get_blink_enabled") GodotMethod!(bool) cursorGetBlinkEnabled; 73 @GodotName("cursor_get_blink_speed") GodotMethod!(double) cursorGetBlinkSpeed; 74 @GodotName("cursor_set_blink_enabled") GodotMethod!(void, bool) cursorSetBlinkEnabled; 75 @GodotName("cursor_set_blink_speed") GodotMethod!(void, double) cursorSetBlinkSpeed; 76 @GodotName("delete_char_at_cursor") GodotMethod!(void) deleteCharAtCursor; 77 @GodotName("delete_text") GodotMethod!(void, long, long) deleteText; 78 @GodotName("deselect") GodotMethod!(void) deselect; 79 @GodotName("get_align") GodotMethod!(LineEdit.Align) getAlign; 80 @GodotName("get_cursor_position") GodotMethod!(long) getCursorPosition; 81 @GodotName("get_expand_to_text_length") GodotMethod!(bool) getExpandToTextLength; 82 @GodotName("get_max_length") GodotMethod!(long) getMaxLength; 83 @GodotName("get_menu") GodotMethod!(PopupMenu) getMenu; 84 @GodotName("get_placeholder") GodotMethod!(String) getPlaceholder; 85 @GodotName("get_placeholder_alpha") GodotMethod!(double) getPlaceholderAlpha; 86 @GodotName("get_right_icon") GodotMethod!(Texture) getRightIcon; 87 @GodotName("get_scroll_offset") GodotMethod!(long) getScrollOffset; 88 @GodotName("get_secret_character") GodotMethod!(String) getSecretCharacter; 89 @GodotName("get_text") GodotMethod!(String) getText; 90 @GodotName("is_clear_button_enabled") GodotMethod!(bool) isClearButtonEnabled; 91 @GodotName("is_context_menu_enabled") GodotMethod!(bool) isContextMenuEnabled; 92 @GodotName("is_editable") GodotMethod!(bool) isEditable; 93 @GodotName("is_secret") GodotMethod!(bool) isSecret; 94 @GodotName("is_selecting_enabled") GodotMethod!(bool) isSelectingEnabled; 95 @GodotName("is_shortcut_keys_enabled") GodotMethod!(bool) isShortcutKeysEnabled; 96 @GodotName("is_virtual_keyboard_enabled") GodotMethod!(bool) isVirtualKeyboardEnabled; 97 @GodotName("menu_option") GodotMethod!(void, long) menuOption; 98 @GodotName("select") GodotMethod!(void, long, long) select; 99 @GodotName("select_all") GodotMethod!(void) selectAll; 100 @GodotName("set_align") GodotMethod!(void, long) setAlign; 101 @GodotName("set_clear_button_enabled") GodotMethod!(void, bool) setClearButtonEnabled; 102 @GodotName("set_context_menu_enabled") GodotMethod!(void, bool) setContextMenuEnabled; 103 @GodotName("set_cursor_position") GodotMethod!(void, long) setCursorPosition; 104 @GodotName("set_editable") GodotMethod!(void, bool) setEditable; 105 @GodotName("set_expand_to_text_length") GodotMethod!(void, bool) setExpandToTextLength; 106 @GodotName("set_max_length") GodotMethod!(void, long) setMaxLength; 107 @GodotName("set_placeholder") GodotMethod!(void, String) setPlaceholder; 108 @GodotName("set_placeholder_alpha") GodotMethod!(void, double) setPlaceholderAlpha; 109 @GodotName("set_right_icon") GodotMethod!(void, Texture) setRightIcon; 110 @GodotName("set_secret") GodotMethod!(void, bool) setSecret; 111 @GodotName("set_secret_character") GodotMethod!(void, String) setSecretCharacter; 112 @GodotName("set_selecting_enabled") GodotMethod!(void, bool) setSelectingEnabled; 113 @GodotName("set_shortcut_keys_enabled") GodotMethod!(void, bool) setShortcutKeysEnabled; 114 @GodotName("set_text") GodotMethod!(void, String) setText; 115 @GodotName("set_virtual_keyboard_enabled") GodotMethod!(void, bool) setVirtualKeyboardEnabled; 116 } 117 /// 118 pragma(inline, true) bool opEquals(in LineEdit other) const 119 { return _godot_object.ptr is other._godot_object.ptr; } 120 /// 121 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 122 { _godot_object.ptr = n; return null; } 123 /// 124 pragma(inline, true) bool opEquals(typeof(null) n) const 125 { return _godot_object.ptr is n; } 126 /// 127 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 128 mixin baseCasts; 129 /// Construct a new instance of LineEdit. 130 /// Note: use `memnew!LineEdit` instead. 131 static LineEdit _new() 132 { 133 static godot_class_constructor constructor; 134 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("LineEdit"); 135 if(constructor is null) return typeof(this).init; 136 return cast(LineEdit)(constructor()); 137 } 138 @disable new(size_t s); 139 /// 140 enum Align : int 141 { 142 /** 143 Aligns the text on the left-hand side of the $(D LineEdit). 144 */ 145 alignLeft = 0, 146 /** 147 Centers the text in the middle of the $(D LineEdit). 148 */ 149 alignCenter = 1, 150 /** 151 Aligns the text on the right-hand side of the $(D LineEdit). 152 */ 153 alignRight = 2, 154 /** 155 Stretches whitespaces to fit the $(D LineEdit)'s width. 156 */ 157 alignFill = 3, 158 } 159 /// 160 enum MenuItems : int 161 { 162 /** 163 Cuts (copies and clears) the selected text. 164 */ 165 menuCut = 0, 166 /** 167 Copies the selected text. 168 */ 169 menuCopy = 1, 170 /** 171 Pastes the clipboard text over the selected text (or at the cursor's position). 172 Non-printable escape characters are automatically stripped from the OS clipboard via $(D String.stripEscapes). 173 */ 174 menuPaste = 2, 175 /** 176 Erases the whole $(D LineEdit) text. 177 */ 178 menuClear = 3, 179 /** 180 Selects the whole $(D LineEdit) text. 181 */ 182 menuSelectAll = 4, 183 /** 184 Undoes the previous action. 185 */ 186 menuUndo = 5, 187 /** 188 Reverse the last undo action. 189 */ 190 menuRedo = 6, 191 /** 192 Represents the size of the $(D menuitems) enum. 193 */ 194 menuMax = 7, 195 } 196 /// 197 enum Constants : int 198 { 199 alignLeft = 0, 200 menuCut = 0, 201 menuCopy = 1, 202 alignCenter = 1, 203 alignRight = 2, 204 menuPaste = 2, 205 alignFill = 3, 206 menuClear = 3, 207 menuSelectAll = 4, 208 menuUndo = 5, 209 menuRedo = 6, 210 menuMax = 7, 211 } 212 /** 213 214 */ 215 void _editorSettingsChanged() 216 { 217 Array _GODOT_args = Array.make(); 218 String _GODOT_method_name = String("_editor_settings_changed"); 219 this.callv(_GODOT_method_name, _GODOT_args); 220 } 221 /** 222 223 */ 224 void _guiInput(InputEvent arg0) 225 { 226 Array _GODOT_args = Array.make(); 227 _GODOT_args.append(arg0); 228 String _GODOT_method_name = String("_gui_input"); 229 this.callv(_GODOT_method_name, _GODOT_args); 230 } 231 /** 232 233 */ 234 void _textChanged() 235 { 236 Array _GODOT_args = Array.make(); 237 String _GODOT_method_name = String("_text_changed"); 238 this.callv(_GODOT_method_name, _GODOT_args); 239 } 240 /** 241 242 */ 243 void _toggleDrawCaret() 244 { 245 Array _GODOT_args = Array.make(); 246 String _GODOT_method_name = String("_toggle_draw_caret"); 247 this.callv(_GODOT_method_name, _GODOT_args); 248 } 249 /** 250 Adds `text` after the cursor. If the resulting value is longer than $(D maxLength), nothing happens. 251 */ 252 void appendAtCursor(in String text) 253 { 254 checkClassBinding!(typeof(this))(); 255 ptrcall!(void)(GDNativeClassBinding.appendAtCursor, _godot_object, text); 256 } 257 /** 258 Erases the $(D LineEdit)'s $(D text). 259 */ 260 void clear() 261 { 262 checkClassBinding!(typeof(this))(); 263 ptrcall!(void)(GDNativeClassBinding.clear, _godot_object); 264 } 265 /** 266 267 */ 268 bool cursorGetBlinkEnabled() const 269 { 270 checkClassBinding!(typeof(this))(); 271 return ptrcall!(bool)(GDNativeClassBinding.cursorGetBlinkEnabled, _godot_object); 272 } 273 /** 274 275 */ 276 double cursorGetBlinkSpeed() const 277 { 278 checkClassBinding!(typeof(this))(); 279 return ptrcall!(double)(GDNativeClassBinding.cursorGetBlinkSpeed, _godot_object); 280 } 281 /** 282 283 */ 284 void cursorSetBlinkEnabled(in bool enabled) 285 { 286 checkClassBinding!(typeof(this))(); 287 ptrcall!(void)(GDNativeClassBinding.cursorSetBlinkEnabled, _godot_object, enabled); 288 } 289 /** 290 291 */ 292 void cursorSetBlinkSpeed(in double blink_speed) 293 { 294 checkClassBinding!(typeof(this))(); 295 ptrcall!(void)(GDNativeClassBinding.cursorSetBlinkSpeed, _godot_object, blink_speed); 296 } 297 /** 298 Deletes one character at the cursor's current position (equivalent to pressing the `Delete` key). 299 */ 300 void deleteCharAtCursor() 301 { 302 checkClassBinding!(typeof(this))(); 303 ptrcall!(void)(GDNativeClassBinding.deleteCharAtCursor, _godot_object); 304 } 305 /** 306 Deletes a section of the $(D text) going from position `from_column` to `to_column`. Both parameters should be within the text's length. 307 */ 308 void deleteText(in long from_column, in long to_column) 309 { 310 checkClassBinding!(typeof(this))(); 311 ptrcall!(void)(GDNativeClassBinding.deleteText, _godot_object, from_column, to_column); 312 } 313 /** 314 Clears the current selection. 315 */ 316 void deselect() 317 { 318 checkClassBinding!(typeof(this))(); 319 ptrcall!(void)(GDNativeClassBinding.deselect, _godot_object); 320 } 321 /** 322 323 */ 324 LineEdit.Align getAlign() const 325 { 326 checkClassBinding!(typeof(this))(); 327 return ptrcall!(LineEdit.Align)(GDNativeClassBinding.getAlign, _godot_object); 328 } 329 /** 330 331 */ 332 long getCursorPosition() const 333 { 334 checkClassBinding!(typeof(this))(); 335 return ptrcall!(long)(GDNativeClassBinding.getCursorPosition, _godot_object); 336 } 337 /** 338 339 */ 340 bool getExpandToTextLength() const 341 { 342 checkClassBinding!(typeof(this))(); 343 return ptrcall!(bool)(GDNativeClassBinding.getExpandToTextLength, _godot_object); 344 } 345 /** 346 347 */ 348 long getMaxLength() const 349 { 350 checkClassBinding!(typeof(this))(); 351 return ptrcall!(long)(GDNativeClassBinding.getMaxLength, _godot_object); 352 } 353 /** 354 Returns the $(D PopupMenu) of this $(D LineEdit). By default, this menu is displayed when right-clicking on the $(D LineEdit). 355 */ 356 PopupMenu getMenu() const 357 { 358 checkClassBinding!(typeof(this))(); 359 return ptrcall!(PopupMenu)(GDNativeClassBinding.getMenu, _godot_object); 360 } 361 /** 362 363 */ 364 String getPlaceholder() const 365 { 366 checkClassBinding!(typeof(this))(); 367 return ptrcall!(String)(GDNativeClassBinding.getPlaceholder, _godot_object); 368 } 369 /** 370 371 */ 372 double getPlaceholderAlpha() const 373 { 374 checkClassBinding!(typeof(this))(); 375 return ptrcall!(double)(GDNativeClassBinding.getPlaceholderAlpha, _godot_object); 376 } 377 /** 378 379 */ 380 Ref!Texture getRightIcon() 381 { 382 checkClassBinding!(typeof(this))(); 383 return ptrcall!(Texture)(GDNativeClassBinding.getRightIcon, _godot_object); 384 } 385 /** 386 Returns the scroll offset due to $(D caretPosition), as a number of characters. 387 */ 388 long getScrollOffset() const 389 { 390 checkClassBinding!(typeof(this))(); 391 return ptrcall!(long)(GDNativeClassBinding.getScrollOffset, _godot_object); 392 } 393 /** 394 395 */ 396 String getSecretCharacter() const 397 { 398 checkClassBinding!(typeof(this))(); 399 return ptrcall!(String)(GDNativeClassBinding.getSecretCharacter, _godot_object); 400 } 401 /** 402 403 */ 404 String getText() const 405 { 406 checkClassBinding!(typeof(this))(); 407 return ptrcall!(String)(GDNativeClassBinding.getText, _godot_object); 408 } 409 /** 410 411 */ 412 bool isClearButtonEnabled() const 413 { 414 checkClassBinding!(typeof(this))(); 415 return ptrcall!(bool)(GDNativeClassBinding.isClearButtonEnabled, _godot_object); 416 } 417 /** 418 419 */ 420 bool isContextMenuEnabled() 421 { 422 checkClassBinding!(typeof(this))(); 423 return ptrcall!(bool)(GDNativeClassBinding.isContextMenuEnabled, _godot_object); 424 } 425 /** 426 427 */ 428 bool isEditable() const 429 { 430 checkClassBinding!(typeof(this))(); 431 return ptrcall!(bool)(GDNativeClassBinding.isEditable, _godot_object); 432 } 433 /** 434 435 */ 436 bool isSecret() const 437 { 438 checkClassBinding!(typeof(this))(); 439 return ptrcall!(bool)(GDNativeClassBinding.isSecret, _godot_object); 440 } 441 /** 442 443 */ 444 bool isSelectingEnabled() const 445 { 446 checkClassBinding!(typeof(this))(); 447 return ptrcall!(bool)(GDNativeClassBinding.isSelectingEnabled, _godot_object); 448 } 449 /** 450 451 */ 452 bool isShortcutKeysEnabled() const 453 { 454 checkClassBinding!(typeof(this))(); 455 return ptrcall!(bool)(GDNativeClassBinding.isShortcutKeysEnabled, _godot_object); 456 } 457 /** 458 459 */ 460 bool isVirtualKeyboardEnabled() const 461 { 462 checkClassBinding!(typeof(this))(); 463 return ptrcall!(bool)(GDNativeClassBinding.isVirtualKeyboardEnabled, _godot_object); 464 } 465 /** 466 Executes a given action as defined in the $(D menuitems) enum. 467 */ 468 void menuOption(in long option) 469 { 470 checkClassBinding!(typeof(this))(); 471 ptrcall!(void)(GDNativeClassBinding.menuOption, _godot_object, option); 472 } 473 /** 474 Selects characters inside $(D LineEdit) between `from` and `to`. By default, `from` is at the beginning and `to` at the end. 475 476 477 text = "Welcome" 478 select() # Will select "Welcome". 479 select(4) # Will select "ome". 480 select(2, 5) # Will select "lco". 481 482 483 */ 484 void select(in long from = 0, in long to = -1) 485 { 486 checkClassBinding!(typeof(this))(); 487 ptrcall!(void)(GDNativeClassBinding.select, _godot_object, from, to); 488 } 489 /** 490 Selects the whole $(D String). 491 */ 492 void selectAll() 493 { 494 checkClassBinding!(typeof(this))(); 495 ptrcall!(void)(GDNativeClassBinding.selectAll, _godot_object); 496 } 497 /** 498 499 */ 500 void setAlign(in long _align) 501 { 502 checkClassBinding!(typeof(this))(); 503 ptrcall!(void)(GDNativeClassBinding.setAlign, _godot_object, _align); 504 } 505 /** 506 507 */ 508 void setClearButtonEnabled(in bool enable) 509 { 510 checkClassBinding!(typeof(this))(); 511 ptrcall!(void)(GDNativeClassBinding.setClearButtonEnabled, _godot_object, enable); 512 } 513 /** 514 515 */ 516 void setContextMenuEnabled(in bool enable) 517 { 518 checkClassBinding!(typeof(this))(); 519 ptrcall!(void)(GDNativeClassBinding.setContextMenuEnabled, _godot_object, enable); 520 } 521 /** 522 523 */ 524 void setCursorPosition(in long position) 525 { 526 checkClassBinding!(typeof(this))(); 527 ptrcall!(void)(GDNativeClassBinding.setCursorPosition, _godot_object, position); 528 } 529 /** 530 531 */ 532 void setEditable(in bool enabled) 533 { 534 checkClassBinding!(typeof(this))(); 535 ptrcall!(void)(GDNativeClassBinding.setEditable, _godot_object, enabled); 536 } 537 /** 538 539 */ 540 void setExpandToTextLength(in bool enabled) 541 { 542 checkClassBinding!(typeof(this))(); 543 ptrcall!(void)(GDNativeClassBinding.setExpandToTextLength, _godot_object, enabled); 544 } 545 /** 546 547 */ 548 void setMaxLength(in long chars) 549 { 550 checkClassBinding!(typeof(this))(); 551 ptrcall!(void)(GDNativeClassBinding.setMaxLength, _godot_object, chars); 552 } 553 /** 554 555 */ 556 void setPlaceholder(in String text) 557 { 558 checkClassBinding!(typeof(this))(); 559 ptrcall!(void)(GDNativeClassBinding.setPlaceholder, _godot_object, text); 560 } 561 /** 562 563 */ 564 void setPlaceholderAlpha(in double alpha) 565 { 566 checkClassBinding!(typeof(this))(); 567 ptrcall!(void)(GDNativeClassBinding.setPlaceholderAlpha, _godot_object, alpha); 568 } 569 /** 570 571 */ 572 void setRightIcon(Texture icon) 573 { 574 checkClassBinding!(typeof(this))(); 575 ptrcall!(void)(GDNativeClassBinding.setRightIcon, _godot_object, icon); 576 } 577 /** 578 579 */ 580 void setSecret(in bool enabled) 581 { 582 checkClassBinding!(typeof(this))(); 583 ptrcall!(void)(GDNativeClassBinding.setSecret, _godot_object, enabled); 584 } 585 /** 586 587 */ 588 void setSecretCharacter(in String character) 589 { 590 checkClassBinding!(typeof(this))(); 591 ptrcall!(void)(GDNativeClassBinding.setSecretCharacter, _godot_object, character); 592 } 593 /** 594 595 */ 596 void setSelectingEnabled(in bool enable) 597 { 598 checkClassBinding!(typeof(this))(); 599 ptrcall!(void)(GDNativeClassBinding.setSelectingEnabled, _godot_object, enable); 600 } 601 /** 602 603 */ 604 void setShortcutKeysEnabled(in bool enable) 605 { 606 checkClassBinding!(typeof(this))(); 607 ptrcall!(void)(GDNativeClassBinding.setShortcutKeysEnabled, _godot_object, enable); 608 } 609 /** 610 611 */ 612 void setText(in String text) 613 { 614 checkClassBinding!(typeof(this))(); 615 ptrcall!(void)(GDNativeClassBinding.setText, _godot_object, text); 616 } 617 /** 618 619 */ 620 void setVirtualKeyboardEnabled(in bool enable) 621 { 622 checkClassBinding!(typeof(this))(); 623 ptrcall!(void)(GDNativeClassBinding.setVirtualKeyboardEnabled, _godot_object, enable); 624 } 625 /** 626 Text alignment as defined in the $(D _align) enum. 627 */ 628 @property LineEdit.Align _align() 629 { 630 return getAlign(); 631 } 632 /// ditto 633 @property void _align(long v) 634 { 635 setAlign(v); 636 } 637 /** 638 If `true`, the caret (visual cursor) blinks. 639 */ 640 @property bool caretBlink() 641 { 642 return cursorGetBlinkEnabled(); 643 } 644 /// ditto 645 @property void caretBlink(bool v) 646 { 647 cursorSetBlinkEnabled(v); 648 } 649 /** 650 Duration (in seconds) of a caret's blinking cycle. 651 */ 652 @property double caretBlinkSpeed() 653 { 654 return cursorGetBlinkSpeed(); 655 } 656 /// ditto 657 @property void caretBlinkSpeed(double v) 658 { 659 cursorSetBlinkSpeed(v); 660 } 661 /** 662 The cursor's position inside the $(D LineEdit). When set, the text may scroll to accommodate it. 663 */ 664 @property long caretPosition() 665 { 666 return getCursorPosition(); 667 } 668 /// ditto 669 @property void caretPosition(long v) 670 { 671 setCursorPosition(v); 672 } 673 /** 674 If `true`, the $(D LineEdit) will show a clear button if `text` is not empty, which can be used to clear the text quickly. 675 */ 676 @property bool clearButtonEnabled() 677 { 678 return isClearButtonEnabled(); 679 } 680 /// ditto 681 @property void clearButtonEnabled(bool v) 682 { 683 setClearButtonEnabled(v); 684 } 685 /** 686 If `true`, the context menu will appear when right-clicked. 687 */ 688 @property bool contextMenuEnabled() 689 { 690 return isContextMenuEnabled(); 691 } 692 /// ditto 693 @property void contextMenuEnabled(bool v) 694 { 695 setContextMenuEnabled(v); 696 } 697 /** 698 If `false`, existing text cannot be modified and new text cannot be added. 699 */ 700 @property bool editable() 701 { 702 return isEditable(); 703 } 704 /// ditto 705 @property void editable(bool v) 706 { 707 setEditable(v); 708 } 709 /** 710 If `true`, the $(D LineEdit) width will increase to stay longer than the $(D text). It will $(B not) compress if the $(D text) is shortened. 711 */ 712 @property bool expandToTextLength() 713 { 714 return getExpandToTextLength(); 715 } 716 /// ditto 717 @property void expandToTextLength(bool v) 718 { 719 setExpandToTextLength(v); 720 } 721 /** 722 Maximum amount of characters that can be entered inside the $(D LineEdit). If `0`, there is no limit. 723 */ 724 @property long maxLength() 725 { 726 return getMaxLength(); 727 } 728 /// ditto 729 @property void maxLength(long v) 730 { 731 setMaxLength(v); 732 } 733 /** 734 Opacity of the $(D placeholderText). From `0` to `1`. 735 */ 736 @property double placeholderAlpha() 737 { 738 return getPlaceholderAlpha(); 739 } 740 /// ditto 741 @property void placeholderAlpha(double v) 742 { 743 setPlaceholderAlpha(v); 744 } 745 /** 746 Text shown when the $(D LineEdit) is empty. It is $(B not) the $(D LineEdit)'s default value (see $(D text)). 747 */ 748 @property String placeholderText() 749 { 750 return getPlaceholder(); 751 } 752 /// ditto 753 @property void placeholderText(String v) 754 { 755 setPlaceholder(v); 756 } 757 /** 758 Sets the icon that will appear in the right end of the $(D LineEdit) if there's no $(D text), or always, if $(D clearButtonEnabled) is set to `false`. 759 */ 760 @property Texture rightIcon() 761 { 762 return getRightIcon(); 763 } 764 /// ditto 765 @property void rightIcon(Texture v) 766 { 767 setRightIcon(v); 768 } 769 /** 770 If `true`, every character is replaced with the secret character (see $(D secretCharacter)). 771 */ 772 @property bool secret() 773 { 774 return isSecret(); 775 } 776 /// ditto 777 @property void secret(bool v) 778 { 779 setSecret(v); 780 } 781 /** 782 The character to use to mask secret input (defaults to "*"). Only a single character can be used as the secret character. 783 */ 784 @property String secretCharacter() 785 { 786 return getSecretCharacter(); 787 } 788 /// ditto 789 @property void secretCharacter(String v) 790 { 791 setSecretCharacter(v); 792 } 793 /** 794 If `false`, it's impossible to select the text using mouse nor keyboard. 795 */ 796 @property bool selectingEnabled() 797 { 798 return isSelectingEnabled(); 799 } 800 /// ditto 801 @property void selectingEnabled(bool v) 802 { 803 setSelectingEnabled(v); 804 } 805 /** 806 If `false`, using shortcuts will be disabled. 807 */ 808 @property bool shortcutKeysEnabled() 809 { 810 return isShortcutKeysEnabled(); 811 } 812 /// ditto 813 @property void shortcutKeysEnabled(bool v) 814 { 815 setShortcutKeysEnabled(v); 816 } 817 /** 818 String value of the $(D LineEdit). 819 $(B Note:) Changing text using this property won't emit the $(D textChanged) signal. 820 */ 821 @property String text() 822 { 823 return getText(); 824 } 825 /// ditto 826 @property void text(String v) 827 { 828 setText(v); 829 } 830 /** 831 If `true`, the native virtual keyboard is shown when focused on platforms that support it. 832 */ 833 @property bool virtualKeyboardEnabled() 834 { 835 return isVirtualKeyboardEnabled(); 836 } 837 /// ditto 838 @property void virtualKeyboardEnabled(bool v) 839 { 840 setVirtualKeyboardEnabled(v); 841 } 842 }