line_edit.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. /*************************************************************************/
  2. /* line_edit.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #include "line_edit.h"
  30. #include "os/keyboard.h"
  31. #include "os/os.h"
  32. #include "print_string.h"
  33. #include "label.h"
  34. void LineEdit::_input_event(InputEvent p_event) {
  35. switch(p_event.type) {
  36. case InputEvent::MOUSE_BUTTON: {
  37. const InputEventMouseButton &b = p_event.mouse_button;
  38. if (b.button_index!=1)
  39. break;
  40. if (b.pressed) {
  41. set_cursor_at_pixel_pos(b.x);
  42. if (b.doubleclick) {
  43. selection.enabled=true;
  44. selection.begin=0;
  45. selection.end=text.length();
  46. selection.doubleclick=true;
  47. }
  48. selection.drag_attempt=false;
  49. if ((cursor_pos<selection.begin) || (cursor_pos>selection.end) || !selection.enabled) {
  50. selection_clear();
  51. selection.cursor_start=cursor_pos;
  52. selection.creating=true;
  53. } else if (selection.enabled) {
  54. selection.drag_attempt=true;
  55. }
  56. // if (!editable)
  57. // non_editable_clicked_signal.call();
  58. update();
  59. } else {
  60. if ( (!selection.creating) && (!selection.doubleclick)) {
  61. selection_clear();
  62. }
  63. selection.creating=false;
  64. selection.doubleclick=false;
  65. // notify to show soft keyboard
  66. notification(NOTIFICATION_FOCUS_ENTER);
  67. }
  68. update();
  69. } break;
  70. case InputEvent::MOUSE_MOTION: {
  71. const InputEventMouseMotion& m=p_event.mouse_motion;
  72. if (m.button_mask&1) {
  73. if (selection.creating) {
  74. set_cursor_at_pixel_pos(m.x);
  75. selection_fill_at_cursor();
  76. }
  77. }
  78. } break;
  79. case InputEvent::KEY: {
  80. const InputEventKey &k =p_event.key;
  81. if (!k.pressed)
  82. return;
  83. unsigned int code = k.scancode;
  84. if (k.mod.command) {
  85. bool handled=true;
  86. switch (code) {
  87. case (KEY_X): { // CUT
  88. if(k.mod.command && editable) {
  89. cut_text();
  90. }
  91. } break;
  92. case (KEY_C): { // COPY
  93. if(k.mod.command) {
  94. copy_text();
  95. }
  96. } break;
  97. case (KEY_V): { // PASTE
  98. if(k.mod.command && editable) {
  99. paste_text();
  100. }
  101. } break;
  102. case (KEY_Z): { // Simple One level undo
  103. if( k.mod.command && editable) {
  104. int old_cursor_pos = cursor_pos;
  105. text = undo_text;
  106. if(old_cursor_pos > text.length()) {
  107. set_cursor_pos(text.length());
  108. } else {
  109. set_cursor_pos(old_cursor_pos);
  110. }
  111. }
  112. emit_signal("text_changed",text);
  113. _change_notify("text");
  114. } break;
  115. case (KEY_U): { // Delete from start to cursor
  116. if( k.mod.command && editable) {
  117. selection_clear();
  118. undo_text = text;
  119. text = text.substr(cursor_pos,text.length()-cursor_pos);
  120. set_cursor_pos(0);
  121. emit_signal("text_changed",text);
  122. _change_notify("text");
  123. }
  124. } break;
  125. case (KEY_Y): { // PASTE (Yank for unix users)
  126. if(k.mod.command && editable) {
  127. paste_text();
  128. }
  129. } break;
  130. case (KEY_K): { // Delete from cursor_pos to end
  131. if(k.mod.command && editable) {
  132. selection_clear();
  133. undo_text = text;
  134. text = text.substr(0,cursor_pos);
  135. emit_signal("text_changed",text);
  136. _change_notify("text");
  137. }
  138. } break;
  139. default: { handled=false;}
  140. }
  141. if (handled) {
  142. accept_event();
  143. return;
  144. }
  145. }
  146. if (!k.mod.alt && !k.mod.meta && !k.mod.command) {
  147. bool handled=true;
  148. switch (code) {
  149. case KEY_ENTER:
  150. case KEY_RETURN: {
  151. emit_signal( "text_entered",text );
  152. // notify to hide soft keyboard
  153. notification(NOTIFICATION_FOCUS_EXIT);
  154. return;
  155. } break;
  156. case KEY_BACKSPACE: {
  157. if (editable) {
  158. undo_text = text;
  159. if (selection.enabled)
  160. selection_delete();
  161. else
  162. delete_char();
  163. }
  164. } break;
  165. case KEY_LEFT: {
  166. shift_selection_check_pre(k.mod.shift);
  167. set_cursor_pos(get_cursor_pos()-1);
  168. shift_selection_check_post(k.mod.shift);
  169. } break;
  170. case KEY_RIGHT: {
  171. shift_selection_check_pre(k.mod.shift);
  172. set_cursor_pos(get_cursor_pos()+1);
  173. shift_selection_check_post(k.mod.shift);
  174. } break;
  175. case KEY_DELETE: {
  176. if (editable) {
  177. undo_text = text;
  178. if (selection.enabled)
  179. selection_delete();
  180. else if (cursor_pos<text.length()) {
  181. set_cursor_pos(get_cursor_pos()+1);
  182. delete_char();
  183. }
  184. }
  185. } break;
  186. case KEY_HOME: {
  187. shift_selection_check_pre(k.mod.shift);
  188. set_cursor_pos(0);
  189. shift_selection_check_post(k.mod.shift);
  190. } break;
  191. case KEY_END: {
  192. shift_selection_check_pre(k.mod.shift);
  193. set_cursor_pos(text.length());
  194. shift_selection_check_post(k.mod.shift);
  195. } break;
  196. default: {
  197. if (k.unicode>=32 && k.scancode!=KEY_DELETE) {
  198. if (editable) {
  199. selection_delete();
  200. CharType ucodestr[2]={k.unicode,0};
  201. append_at_cursor(ucodestr);
  202. emit_signal("text_changed",text);
  203. _change_notify("text");
  204. }
  205. } else {
  206. handled=false;
  207. }
  208. } break;
  209. }
  210. if (handled)
  211. accept_event();
  212. else
  213. return;
  214. selection.old_shift=k.mod.shift;
  215. update();
  216. }
  217. return;
  218. } break;
  219. }
  220. }
  221. Variant LineEdit::get_drag_data(const Point2& p_point) {
  222. if (selection.drag_attempt && selection.enabled) {
  223. String t = text.substr(selection.begin, selection.end - selection.begin);
  224. Label *l = memnew( Label );
  225. l->set_text(t);
  226. set_drag_preview(l);
  227. return t;
  228. }
  229. return Variant();
  230. }
  231. bool LineEdit::can_drop_data(const Point2& p_point,const Variant& p_data) const{
  232. return p_data.get_type()==Variant::STRING;
  233. }
  234. void LineEdit::drop_data(const Point2& p_point,const Variant& p_data){
  235. if (p_data.get_type()==Variant::STRING) {
  236. set_cursor_at_pixel_pos(p_point.x);
  237. int selected = selection.end - selection.begin;
  238. text.erase(selection.begin, selected);
  239. append_at_cursor(p_data);
  240. selection.begin = cursor_pos-selected;
  241. selection.end = cursor_pos;
  242. }
  243. }
  244. void LineEdit::_notification(int p_what) {
  245. switch(p_what) {
  246. case NOTIFICATION_RESIZED: {
  247. set_cursor_pos( get_cursor_pos() );
  248. } break;
  249. case NOTIFICATION_DRAW: {
  250. int width,height;
  251. Size2 size=get_size();
  252. width=size.width;
  253. height=size.height;
  254. RID ci = get_canvas_item();
  255. Ref<StyleBox> style = get_stylebox("normal");
  256. if (!is_editable())
  257. style=get_stylebox("read_only");
  258. Ref<Font> font=get_font("font");
  259. style->draw( ci, Rect2( Point2(), size ) );
  260. if (has_focus()) {
  261. get_stylebox("focus")->draw( ci, Rect2( Point2(), size ) );
  262. }
  263. int ofs=style->get_offset().x;
  264. int ofs_max=width-style->get_minimum_size().width;
  265. int char_ofs=window_pos;
  266. int y_area=height-style->get_minimum_size().height;
  267. int y_ofs=style->get_offset().y;
  268. int font_ascent=font->get_ascent();
  269. Color selection_color=get_color("selection_color");
  270. Color font_color=get_color("font_color");
  271. Color font_color_selected=get_color("font_color_selected");
  272. Color cursor_color=get_color("cursor_color");
  273. while(true) {
  274. //end of string, break!
  275. if (char_ofs>=text.length())
  276. break;
  277. CharType cchar=pass?'*':text[char_ofs];
  278. CharType next=pass?'*':text[char_ofs+1];
  279. int char_width=font->get_char_size( cchar,next ).width;
  280. // end of widget, break!
  281. if ( (ofs+char_width) > ofs_max )
  282. break;
  283. bool selected=selection.enabled && char_ofs>=selection.begin && char_ofs<selection.end;
  284. if (selected)
  285. VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2( Point2( ofs , y_ofs ),Size2( char_width, y_area )),selection_color);
  286. font->draw_char(ci,Point2( ofs , y_ofs+font_ascent ), cchar, next,selected?font_color_selected:font_color );
  287. if (char_ofs==cursor_pos && has_focus())
  288. VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
  289. Point2( ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color );
  290. ofs+=char_width;
  291. char_ofs++;
  292. }
  293. if (char_ofs==cursor_pos && has_focus()) //may be at the end
  294. VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
  295. Point2( ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color );
  296. } break;
  297. case NOTIFICATION_FOCUS_ENTER: {
  298. if (OS::get_singleton()->has_virtual_keyboard())
  299. OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect());
  300. } break;
  301. case NOTIFICATION_FOCUS_EXIT: {
  302. if (OS::get_singleton()->has_virtual_keyboard())
  303. OS::get_singleton()->hide_virtual_keyboard();
  304. } break;
  305. }
  306. }
  307. void LineEdit::copy_text() {
  308. if(selection.enabled) {
  309. OS::get_singleton()->set_clipboard(text.substr(selection.begin, selection.end - selection.begin));
  310. }
  311. }
  312. void LineEdit::cut_text() {
  313. if(selection.enabled) {
  314. undo_text = text;
  315. OS::get_singleton()->set_clipboard(text.substr(selection.begin, selection.end - selection.begin));
  316. selection_delete();
  317. }
  318. }
  319. void LineEdit::paste_text() {
  320. String paste_buffer = OS::get_singleton()->get_clipboard();
  321. if(paste_buffer != "") {
  322. if(selection.enabled) selection_delete();
  323. append_at_cursor(paste_buffer);
  324. emit_signal("text_changed",text);
  325. _change_notify("text");
  326. }
  327. }
  328. void LineEdit::shift_selection_check_pre(bool p_shift) {
  329. if (!selection.old_shift && p_shift) {
  330. selection.cursor_start=cursor_pos;
  331. }
  332. if (!p_shift)
  333. selection_clear();
  334. }
  335. void LineEdit::shift_selection_check_post(bool p_shift) {
  336. if (p_shift)
  337. selection_fill_at_cursor();
  338. }
  339. void LineEdit::set_cursor_at_pixel_pos(int p_x) {
  340. int ofs=window_pos;
  341. int pixel_ofs=get_stylebox("normal")->get_offset().x;
  342. Ref<Font> font=get_font("font");
  343. while (ofs<text.length()) {
  344. int char_w=font->get_char_size( text[ofs] ).width;
  345. pixel_ofs+=char_w;
  346. if (pixel_ofs > p_x) { //found what we look for
  347. if ( (pixel_ofs-p_x) < (char_w >> 1 ) ) {
  348. ofs+=1;
  349. }
  350. break;
  351. }
  352. ofs++;
  353. }
  354. set_cursor_pos( ofs );
  355. /*
  356. int new_cursor_pos=p_x;
  357. int charwidth=draw_area->get_font_char_width(' ',0);
  358. new_cursor_pos=( ( (new_cursor_pos-2)+ (charwidth/2) ) /charwidth );
  359. if (new_cursor_pos>(int)text.length()) new_cursor_pos=text.length();
  360. set_cursor_pos(window_pos+new_cursor_pos); */
  361. }
  362. void LineEdit::delete_char() {
  363. if ((text.length()<=0) || (cursor_pos==0)) return;
  364. text.erase( cursor_pos-1, 1 );
  365. set_cursor_pos(get_cursor_pos()-1);
  366. if (cursor_pos==window_pos) {
  367. // set_window_pos(cursor_pos-get_window_length());
  368. }
  369. emit_signal("text_changed",text);
  370. _change_notify("text");
  371. }
  372. void LineEdit::set_text(String p_text) {
  373. clear_internal();
  374. append_at_cursor(p_text);
  375. update();
  376. cursor_pos=0;
  377. window_pos=0;
  378. }
  379. void LineEdit::clear() {
  380. clear_internal();
  381. }
  382. String LineEdit::get_text() const {
  383. return text;
  384. }
  385. void LineEdit::set_cursor_pos(int p_pos) {
  386. if (p_pos>(int)text.length())
  387. p_pos=text.length();
  388. if(p_pos<0)
  389. p_pos=0;
  390. cursor_pos=p_pos;
  391. // if (cursor_pos>(window_pos+get_window_length())) {
  392. // set_window_pos(cursor_pos-get_window_lengt//h());
  393. // }
  394. if (!is_inside_scene()) {
  395. window_pos=cursor_pos;
  396. return;
  397. }
  398. Ref<StyleBox> style = get_stylebox("normal");
  399. Ref<Font> font=get_font("font");
  400. if (cursor_pos<window_pos) {
  401. /* Adjust window if cursor goes too much to the left */
  402. set_window_pos(cursor_pos);
  403. } else if (cursor_pos>window_pos) {
  404. /* Adjust window if cursor goes too much to the right */
  405. int window_width=get_size().width-style->get_minimum_size().width;
  406. if (window_width<0)
  407. return;
  408. int width_to_cursor=0;
  409. int wp=window_pos;
  410. for (int i=window_pos;i<cursor_pos;i++)
  411. width_to_cursor+=font->get_char_size( text[i] ).width;
  412. while(width_to_cursor>=window_width && wp<text.length()) {
  413. width_to_cursor-=font->get_char_size( text[ wp ] ).width;
  414. wp++;
  415. }
  416. if (wp!=window_pos)
  417. set_window_pos( wp );
  418. }
  419. update();
  420. }
  421. int LineEdit::get_cursor_pos() const {
  422. return cursor_pos;
  423. }
  424. void LineEdit::set_window_pos(int p_pos) {
  425. window_pos=p_pos;
  426. if (window_pos<0) window_pos=0;
  427. }
  428. void LineEdit::append_at_cursor(String p_text) {
  429. if ( ( max_length <= 0 ) || (text.length()+p_text.length() <= max_length)) {
  430. undo_text = text;
  431. String pre = text.substr( 0, cursor_pos );
  432. String post = text.substr( cursor_pos, text.length()-cursor_pos );
  433. text=pre+p_text+post;
  434. set_cursor_pos(cursor_pos+p_text.length());
  435. }
  436. }
  437. void LineEdit::clear_internal() {
  438. cursor_pos=0;
  439. window_pos=0;
  440. undo_text="";
  441. text="";
  442. update();
  443. }
  444. Size2 LineEdit::get_minimum_size() const {
  445. Ref<StyleBox> style = get_stylebox("normal");
  446. Ref<Font> font=get_font("font");
  447. Size2 min=style->get_minimum_size();
  448. min.height+=font->get_height();
  449. min.width+=get_constant("minimum_spaces")*font->get_char_size(' ').x;
  450. return min;
  451. }
  452. /* selection */
  453. void LineEdit::selection_clear() {
  454. selection.begin=0;
  455. selection.end=0;
  456. selection.cursor_start=0;
  457. selection.enabled=false;
  458. selection.creating=false;
  459. selection.old_shift=false;
  460. selection.doubleclick=false;
  461. update();
  462. }
  463. void LineEdit::selection_delete() {
  464. if (selection.enabled) {
  465. undo_text = text;
  466. text.erase(selection.begin,selection.end-selection.begin);
  467. if (cursor_pos>=text.length()) {
  468. cursor_pos=text.length();
  469. }
  470. if (window_pos>cursor_pos) {
  471. window_pos=cursor_pos;
  472. }
  473. emit_signal("text_changed",text);
  474. _change_notify("text");
  475. };
  476. selection_clear();
  477. }
  478. void LineEdit::set_max_length(int p_max_length) {
  479. ERR_FAIL_COND(p_max_length<0);
  480. max_length = p_max_length;
  481. set_text(text);
  482. }
  483. int LineEdit::get_max_length() const {
  484. return max_length;
  485. }
  486. void LineEdit::selection_fill_at_cursor() {
  487. int aux;
  488. selection.begin=cursor_pos;
  489. selection.end=selection.cursor_start;
  490. if (selection.end<selection.begin) {
  491. aux=selection.end;
  492. selection.end=selection.begin;
  493. selection.begin=aux;
  494. }
  495. selection.enabled=(selection.begin!=selection.end);
  496. }
  497. void LineEdit::select_all() {
  498. if (!text.length())
  499. return;
  500. selection.begin=0;
  501. selection.end=text.length();
  502. selection.enabled=true;
  503. update();
  504. }
  505. void LineEdit::set_editable(bool p_editable) {
  506. editable=p_editable;
  507. update();
  508. }
  509. bool LineEdit::is_editable() const {
  510. return editable;
  511. }
  512. void LineEdit::set_secret(bool p_secret) {
  513. pass=p_secret;
  514. update();
  515. }
  516. bool LineEdit::is_secret() const {
  517. return pass;
  518. }
  519. void LineEdit::select(int p_from, int p_to) {
  520. if (p_from==0 && p_to==0) {
  521. selection_clear();
  522. return;
  523. }
  524. int len = text.length();
  525. if (p_from<0)
  526. p_from=0;
  527. if (p_from>len)
  528. p_from=len;
  529. if (p_to<0 || p_to>len)
  530. p_to=len;
  531. if (p_from>=p_to)
  532. return;
  533. selection.enabled=true;
  534. selection.begin=p_from;
  535. selection.end=p_to;
  536. selection.creating=false;
  537. selection.old_shift=false;
  538. selection.doubleclick=false;
  539. update();
  540. }
  541. void LineEdit::_bind_methods() {
  542. ObjectTypeDB::bind_method(_MD("_input_event"),&LineEdit::_input_event);
  543. ObjectTypeDB::bind_method(_MD("clear"),&LineEdit::clear);
  544. ObjectTypeDB::bind_method(_MD("select_all"),&LineEdit::select_all);
  545. ObjectTypeDB::bind_method(_MD("set_text","text"),&LineEdit::set_text);
  546. ObjectTypeDB::bind_method(_MD("get_text"),&LineEdit::get_text);
  547. ObjectTypeDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
  548. ObjectTypeDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
  549. ObjectTypeDB::bind_method(_MD("set_max_length","chars"),&LineEdit::set_max_length);
  550. ObjectTypeDB::bind_method(_MD("get_max_length"),&LineEdit::get_max_length);
  551. ObjectTypeDB::bind_method(_MD("append_at_cursor","text"),&LineEdit::append_at_cursor);
  552. ObjectTypeDB::bind_method(_MD("set_editable","enabled"),&LineEdit::set_editable);
  553. ObjectTypeDB::bind_method(_MD("is_editable"),&LineEdit::is_editable);
  554. ObjectTypeDB::bind_method(_MD("set_secret","enabled"),&LineEdit::set_secret);
  555. ObjectTypeDB::bind_method(_MD("is_secret"),&LineEdit::is_secret);
  556. ObjectTypeDB::bind_method(_MD("select","from","to"),&LineEdit::select,DEFVAL(0),DEFVAL(-1));
  557. ADD_SIGNAL( MethodInfo("text_changed", PropertyInfo( Variant::STRING, "text" )) );
  558. ADD_SIGNAL( MethodInfo("text_entered", PropertyInfo( Variant::STRING, "text" )) );
  559. ADD_PROPERTY( PropertyInfo( Variant::STRING, "text" ), _SCS("set_text"),_SCS("get_text") );
  560. ADD_PROPERTY( PropertyInfo( Variant::INT, "max_length" ), _SCS("set_max_length"),_SCS("get_max_length") );
  561. ADD_PROPERTY( PropertyInfo( Variant::BOOL, "editable" ), _SCS("set_editable"),_SCS("is_editable") );
  562. ADD_PROPERTY( PropertyInfo( Variant::BOOL, "secret" ), _SCS("set_secret"),_SCS("is_secret") );
  563. }
  564. LineEdit::LineEdit() {
  565. cursor_pos=0;
  566. window_pos=0;
  567. max_length = 0;
  568. pass=false;
  569. selection_clear();
  570. set_focus_mode( FOCUS_ALL );
  571. editable=true;
  572. set_default_cursor_shape(CURSOR_IBEAM);
  573. set_stop_mouse(true);
  574. }
  575. LineEdit::~LineEdit() {
  576. }