Source

cappuccino-docs / cappuccino docs / cappuccino.org / learn / documentation / _c_p_text_field_8j_source.html

Full commit
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!-- Mirrored from cappuccino.org/learn/documentation/_c_p_text_field_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:31 GMT -->
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Cappuccino API: AppKit/CPTextField.j Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>AppKit/CPTextField.j</h1><a href="_c_p_text_field_8j.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">/*</span>
<a name="l00003"></a>00003 <span class="comment"> * CPTextField.j</span>
<a name="l00004"></a>00004 <span class="comment"> * AppKit</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * Created by Francisco Tolmasky.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright 2008, 280 North, Inc.</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
<a name="l00010"></a>00010 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
<a name="l00011"></a>00011 <span class="comment"> * License as published by the Free Software Foundation; either</span>
<a name="l00012"></a>00012 <span class="comment"> * version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
<a name="l00017"></a>00017 <span class="comment"> * Lesser General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
<a name="l00020"></a>00020 <span class="comment"> * License along with this library; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00022"></a>00022 <span class="comment"> */</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPControl.j&quot;</span>
<a name="l00025"></a>00025 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPStringDrawing.j&quot;</span>
<a name="l00026"></a>00026 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPCompatibility.j&quot;</span>
<a name="l00027"></a>00027 @<span class="keyword">import</span> <span class="stringliteral">&quot;_CPImageAndTextView.j&quot;</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="_c_g_geometry_8h.html">CoreGraphics/CGGeometry.h</a>&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;<a class="code" href="_platform_8h.html">Platform/Platform.h</a>&quot;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;<a class="code" href="_c_p_d_o_m_display_server_8h.html">Platform/DOM/CPDOMDisplayServer.h</a>&quot;</span>
<a name="l00032"></a>00032 
<a name="l00033"></a><a class="code" href="_c_p_text_field_8j.html#a0a4ebf79bcabaa98ab2adaad9ba4a7ec">00033</a> <a class="code" href="_c_p_text_field_8j.html#a0a4ebf79bcabaa98ab2adaad9ba4a7ec">CPTextFieldSquareBezel</a>          = 0;    
<a name="l00034"></a><a class="code" href="_c_p_text_field_8j.html#a50bacf57c023263265f5f1e7e681489d">00034</a> <a class="code" href="_c_p_text_field_8j.html#a50bacf57c023263265f5f1e7e681489d">CPTextFieldRoundedBezel</a>         = 1;    
<a name="l00036"></a><a class="code" href="_c_p_text_field_8j.html#af7a1afda2e12f9d6a5bdfe9e954a4594">00036</a> <a class="code" href="_c_p_text_field_8j.html#af7a1afda2e12f9d6a5bdfe9e954a4594">CPTextFieldDidFocusNotification</a> = <span class="stringliteral">@&quot;CPTextFieldDidFocusNotification&quot;</span>;
<a name="l00037"></a><a class="code" href="_c_p_text_field_8j.html#a03f3e71001d935245f780ead0bcb381b">00037</a> <a class="code" href="_c_p_text_field_8j.html#a03f3e71001d935245f780ead0bcb381b">CPTextFieldDidBlurNotification</a>  = <span class="stringliteral">@&quot;CPTextFieldDidBlurNotification&quot;</span>;
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="preprocessor">#if PLATFORM(DOM)</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span>
<a name="l00041"></a>00041 var CPTextFieldDOMInputElement = nil,
<a name="l00042"></a>00042     CPTextFieldDOMPasswordInputElement = nil,
<a name="l00043"></a>00043     CPTextFieldDOMStandardInputElement = nil,
<a name="l00044"></a>00044     CPTextFieldInputOwner = nil,
<a name="l00045"></a>00045     CPTextFieldTextDidChangeValue = nil,
<a name="l00046"></a>00046     CPTextFieldInputResigning = NO,
<a name="l00047"></a>00047     CPTextFieldInputDidBlur = NO,
<a name="l00048"></a>00048     CPTextFieldInputIsActive = NO,
<a name="l00049"></a>00049     CPTextFieldCachedSelectStartFunction = nil,
<a name="l00050"></a>00050     CPTextFieldCachedDragFunction = nil,
<a name="l00051"></a>00051     CPTextFieldBlurFunction = nil;
<a name="l00052"></a>00052     
<a name="l00053"></a>00053 <span class="preprocessor">#endif</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span>
<a name="l00055"></a><a class="code" href="_c_p_text_field_8j.html#a980528c034ab9ad8a4fe446d70394a5c">00055</a> var <a class="code" href="_c_p_text_field_8j.html#a980528c034ab9ad8a4fe446d70394a5c">CPSecureTextFieldCharacter</a> = <span class="stringliteral">&quot;\u2022&quot;</span>;
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="keyword">@implementation </span><a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a> (CPTextFieldAdditions)
<a name="l00058"></a>00058 
<a name="l00062"></a><a class="code" href="class_c_p_string.html#a2c829cdee6f107947e586c96b4d7237b">00062</a> - (<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)<a class="code" href="class_c_p_string.html#a2c829cdee6f107947e586c96b4d7237b">string</a>
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066 
<a name="l00067"></a>00067 <span class="keyword">@end</span>
<a name="l00068"></a>00068 
<a name="l00069"></a><a class="code" href="_c_p_text_field_8j.html#a83312094a6f7f1255a156d27cc88a4a9">00069</a> <a class="code" href="_c_p_text_field_8j.html#a83312094a6f7f1255a156d27cc88a4a9">CPTextFieldStateRounded</a>     = <a class="code" href="_c_p_theme_8j.html#ad6e2552ced62697350961183fed236ac">CPThemeState</a>(<span class="stringliteral">&quot;rounded&quot;</span>);
<a name="l00070"></a><a class="code" href="_c_p_text_field_8j.html#ace23af555767a4e15bdeb9ae1f86b5f4">00070</a> <a class="code" href="_c_p_text_field_8j.html#ace23af555767a4e15bdeb9ae1f86b5f4">CPTextFieldStatePlaceholder</a> = <a class="code" href="_c_p_theme_8j.html#ad6e2552ced62697350961183fed236ac">CPThemeState</a>(<span class="stringliteral">&quot;placeholder&quot;</span>);
<a name="l00071"></a>00071 
<a name="l00076"></a><a class="code" href="class_c_p_text_field.html">00076</a> <span class="keyword">@implementation </span><a class="code" href="class_c_p_text_field.html">CPTextField</a> : <a class="code" href="class_c_p_control.html">CPControl</a>
<a name="l00077"></a>00077 {
<a name="l00078"></a>00078     BOOL                    _isEditing;
<a name="l00079"></a>00079 
<a name="l00080"></a>00080     BOOL                    _isEditable;
<a name="l00081"></a>00081     BOOL                    _isSelectable;
<a name="l00082"></a>00082     BOOL                    _isSecure;
<a name="l00083"></a>00083 
<a name="l00084"></a>00084     BOOL                    _drawsBackground;
<a name="l00085"></a>00085     
<a name="l00086"></a>00086     <a class="code" href="class_c_p_color.html">CPColor</a>                 _textFieldBackgroundColor;
<a name="l00087"></a>00087     
<a name="l00088"></a>00088     <span class="keywordtype">id</span>                      _placeholderString;
<a name="l00089"></a>00089     
<a name="l00090"></a>00090     <span class="keywordtype">id</span>                      _delegate;
<a name="l00091"></a>00091     
<a name="l00092"></a>00092     <a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>                _textDidChangeValue;
<a name="l00093"></a>00093 
<a name="l00094"></a>00094     <span class="comment">// NS-style Display Properties</span>
<a name="l00095"></a>00095     CPTextFieldBezelStyle   _bezelStyle;
<a name="l00096"></a>00096     BOOL                    _isBordered;
<a name="l00097"></a>00097     CPControlSize           _controlSize;
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 
<a name="l00100"></a><a class="code" href="class_c_p_text_field.html#a0eebea8f1c3abfa68dd29b8888d53bc8">00100</a> + (<a class="code" href="class_c_p_text_field.html">CPTextField</a>)textFieldWithStringValue:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aStringValue placeholder:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aPlaceholder width:(<span class="keywordtype">float</span>)aWidth
<a name="l00101"></a>00101 {
<a name="l00102"></a>00102     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#ab2773fabb2c03ba7c84f1d967dd73042">textFieldWithStringValue</a>:aStringValue <a class="code" href="class_c_p_text_field.html#ab2773fabb2c03ba7c84f1d967dd73042">placeholder</a>:aPlaceholder <a class="code" href="class_c_p_text_field.html#ab2773fabb2c03ba7c84f1d967dd73042">width</a>:aWidth <a class="code" href="class_c_p_text_field.html#ab2773fabb2c03ba7c84f1d967dd73042">theme</a>:[<a class="code" href="class_c_p_theme.html">CPTheme</a> <a class="code" href="class_c_p_theme.html#a19028d2f26f8d89be574ebdbdcfa5f16">defaultTheme</a>]];
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 
<a name="l00105"></a><a class="code" href="class_c_p_text_field.html#ab2773fabb2c03ba7c84f1d967dd73042">00105</a> + (<a class="code" href="class_c_p_text_field.html">CPTextField</a>)textFieldWithStringValue:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aStringValue placeholder:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aPlaceholder width:(<span class="keywordtype">float</span>)aWidth theme:(<a class="code" href="class_c_p_theme.html">CPTheme</a>)aTheme
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107     var textField = [[<span class="keyword">self</span> alloc] initWithFrame:CGRectMake(0.0, 0.0, aWidth, 29.0)];
<a name="l00108"></a>00108 
<a name="l00109"></a>00109     [textField setTheme:aTheme];
<a name="l00110"></a>00110     [textField setStringValue:aStringValue];
<a name="l00111"></a>00111     [textField setPlaceholderString:aPlaceholder];
<a name="l00112"></a>00112     [textField setBordered:YES];
<a name="l00113"></a>00113     [textField setBezeled:YES];
<a name="l00114"></a>00114     [textField setEditable:YES];
<a name="l00115"></a>00115 
<a name="l00116"></a>00116     [textField sizeToFit];
<a name="l00117"></a>00117 
<a name="l00118"></a>00118     <span class="keywordflow">return</span> textField;
<a name="l00119"></a>00119 }
<a name="l00120"></a>00120 
<a name="l00121"></a><a class="code" href="class_c_p_text_field.html#a265229cbb7463339b9cf6798848c3264">00121</a> + (<a class="code" href="class_c_p_text_field.html">CPTextField</a>)roundedTextFieldWithStringValue:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aStringValue placeholder:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aPlaceholder width:(<span class="keywordtype">float</span>)aWidth
<a name="l00122"></a>00122 {
<a name="l00123"></a>00123     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#ae1c5dd7b9f54e9538abd9e1da0ba1da6">roundedTextFieldWithStringValue</a>:aStringValue <a class="code" href="class_c_p_text_field.html#ae1c5dd7b9f54e9538abd9e1da0ba1da6">placeholder</a>:aPlaceholder <a class="code" href="class_c_p_text_field.html#ae1c5dd7b9f54e9538abd9e1da0ba1da6">width</a>:aWidth <a class="code" href="class_c_p_text_field.html#ae1c5dd7b9f54e9538abd9e1da0ba1da6">theme</a>:[<a class="code" href="class_c_p_theme.html">CPTheme</a> <a class="code" href="class_c_p_theme.html#a19028d2f26f8d89be574ebdbdcfa5f16">defaultTheme</a>]];
<a name="l00124"></a>00124 }
<a name="l00125"></a>00125 
<a name="l00126"></a><a class="code" href="class_c_p_text_field.html#ae1c5dd7b9f54e9538abd9e1da0ba1da6">00126</a> + (<a class="code" href="class_c_p_text_field.html">CPTextField</a>)roundedTextFieldWithStringValue:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aStringValue placeholder:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aPlaceholder width:(<span class="keywordtype">float</span>)aWidth theme:(<a class="code" href="class_c_p_theme.html">CPTheme</a>)aTheme
<a name="l00127"></a>00127 {
<a name="l00128"></a>00128     var textField = [[<a class="code" href="class_c_p_text_field.html">CPTextField</a> alloc] initWithFrame:CGRectMake(0.0, 0.0, aWidth, 29.0)];
<a name="l00129"></a>00129 
<a name="l00130"></a>00130     [textField setTheme:aTheme];
<a name="l00131"></a>00131     [textField setStringValue:aStringValue];
<a name="l00132"></a>00132     [textField setPlaceholderString:aPlaceholder];
<a name="l00133"></a>00133     [textField setBezelStyle:CPTextFieldRoundedBezel];
<a name="l00134"></a>00134     [textField setBordered:YES];
<a name="l00135"></a>00135     [textField setBezeled:YES];
<a name="l00136"></a>00136     [textField setEditable:YES];
<a name="l00137"></a>00137 
<a name="l00138"></a>00138     [textField sizeToFit];
<a name="l00139"></a>00139 
<a name="l00140"></a>00140     <span class="keywordflow">return</span> textField;
<a name="l00141"></a>00141 }
<a name="l00142"></a>00142 
<a name="l00143"></a><a class="code" href="class_c_p_text_field.html#ad2ca49190430fc78159edbe68e148c4d">00143</a> + (<a class="code" href="class_c_p_text_field.html">CPTextField</a>)labelWithTitle:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aTitle
<a name="l00144"></a>00144 {
<a name="l00145"></a>00145     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a261a0cf71370fab4767b29cee1317437">labelWithTitle</a>:aTitle <a class="code" href="class_c_p_text_field.html#a261a0cf71370fab4767b29cee1317437">theme</a>:[<a class="code" href="class_c_p_theme.html">CPTheme</a> <a class="code" href="class_c_p_theme.html#a19028d2f26f8d89be574ebdbdcfa5f16">defaultTheme</a>]];
<a name="l00146"></a>00146 }
<a name="l00147"></a>00147 
<a name="l00148"></a><a class="code" href="class_c_p_text_field.html#a261a0cf71370fab4767b29cee1317437">00148</a> + (<a class="code" href="class_c_p_text_field.html">CPTextField</a>)labelWithTitle:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aTitle theme:(<a class="code" href="class_c_p_theme.html">CPTheme</a>)aTheme
<a name="l00149"></a>00149 {
<a name="l00150"></a>00150     var textField = [[<span class="keyword">self</span> alloc] init];
<a name="l00151"></a>00151 
<a name="l00152"></a>00152     [textField setStringValue:aTitle];
<a name="l00153"></a>00153     [textField sizeToFit];
<a name="l00154"></a>00154 
<a name="l00155"></a>00155     <span class="keywordflow">return</span> textField;
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157 
<a name="l00158"></a><a class="code" href="class_c_p_text_field.html#a033cd8cb9ab7ed68d7ee0cc54b1816b2">00158</a> + (<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)themeClass
<a name="l00159"></a>00159 {
<a name="l00160"></a>00160     <span class="keywordflow">return</span> <span class="stringliteral">&quot;textfield&quot;</span>;
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 
<a name="l00163"></a><a class="code" href="class_c_p_text_field.html#a9635cfc6f5549dae7ed7ee57702fa775">00163</a> + (id)themeAttributes
<a name="l00164"></a>00164 {
<a name="l00165"></a>00165     <span class="keywordflow">return</span> [<a class="code" href="class_c_p_dictionary.html" title="A mutable key-value pair collection.">CPDictionary</a> <a class="code" href="class_c_p_dictionary.html#ac4d7617692c892eaed4d00de281c4c83">dictionaryWithObjects</a>:[_CGInsetMakeZero(), _CGInsetMake(2.0, 2.0, 2.0, 2.0), [<a class="code" href="class_c_p_null.html" title="An object representation of nil.">CPNull</a> null]]
<a name="l00166"></a>00166                                        <a class="code" href="class_c_p_dictionary.html#ac4d7617692c892eaed4d00de281c4c83">forKeys</a>:[@&quot;bezel-inset&quot;, @&quot;content-inset&quot;, @&quot;bezel-color&quot;]];
<a name="l00167"></a>00167 }
<a name="l00168"></a>00168 
<a name="l00169"></a>00169 <span class="comment">/* @ignore */</span>
<a name="l00170"></a>00170 <span class="preprocessor">#if PLATFORM(DOM)</span>
<a name="l00171"></a>00171 <span class="preprocessor"></span>- (DOMElement)_inputElement
<a name="l00172"></a>00172 {
<a name="l00173"></a>00173     <span class="keywordflow">if</span> (!CPTextFieldDOMInputElement)
<a name="l00174"></a>00174     {
<a name="l00175"></a>00175         CPTextFieldDOMInputElement = document.createElement(<span class="stringliteral">&quot;input&quot;</span>);
<a name="l00176"></a>00176         CPTextFieldDOMInputElement.style.position = <span class="stringliteral">&quot;absolute&quot;</span>;
<a name="l00177"></a>00177         CPTextFieldDOMInputElement.style.border = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00178"></a>00178         CPTextFieldDOMInputElement.style.padding = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00179"></a>00179         CPTextFieldDOMInputElement.style.margin = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00180"></a>00180         CPTextFieldDOMInputElement.style.whiteSpace = <span class="stringliteral">&quot;pre&quot;</span>;
<a name="l00181"></a>00181         CPTextFieldDOMInputElement.style.background = <span class="stringliteral">&quot;transparent&quot;</span>;
<a name="l00182"></a>00182         CPTextFieldDOMInputElement.style.outline = <span class="stringliteral">&quot;none&quot;</span>;
<a name="l00183"></a>00183 
<a name="l00184"></a>00184         CPTextFieldBlurFunction = function(anEvent)
<a name="l00185"></a>00185         {
<a name="l00186"></a>00186             <span class="keywordflow">if</span> (CPTextFieldInputOwner &amp;&amp; CPTextFieldInputOwner._DOMElement != CPTextFieldDOMInputElement.parentNode)
<a name="l00187"></a>00187                 <span class="keywordflow">return</span>;
<a name="l00188"></a>00188 
<a name="l00189"></a>00189             <span class="keywordflow">if</span> (!CPTextFieldInputResigning)
<a name="l00190"></a>00190             {
<a name="l00191"></a>00191                 [[CPTextFieldInputOwner window] makeFirstResponder:nil];
<a name="l00192"></a>00192                 <span class="keywordflow">return</span>;
<a name="l00193"></a>00193             }
<a name="l00194"></a>00194 
<a name="l00195"></a>00195             CPTextFieldHandleBlur(anEvent, CPTextFieldDOMInputElement);
<a name="l00196"></a>00196             CPTextFieldInputDidBlur = YES;
<a name="l00197"></a>00197 
<a name="l00198"></a>00198             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00199"></a>00199         }
<a name="l00200"></a>00200 
<a name="l00201"></a>00201         CPTextFieldHandleBlur = function(anEvent)
<a name="l00202"></a>00202         {            
<a name="l00203"></a>00203             CPTextFieldInputOwner = nil;
<a name="l00204"></a>00204 
<a name="l00205"></a>00205             [[<a class="code" href="class_c_p_run_loop.html" title="The main run loop for the application.">CPRunLoop</a> <a class="code" href="class_c_p_run_loop.html#aba93f1cef957bad4353ce060981c0b9d">currentRunLoop</a>] <a class="code" href="class_c_p_run_loop.html#aad8e51e44d4c17634d8c45c1ca540217">limitDateForMode</a>:CPDefaultRunLoopMode];
<a name="l00206"></a>00206         }
<a name="l00207"></a>00207 
<a name="l00208"></a>00208         <span class="comment">//FIXME make this not onblur</span>
<a name="l00209"></a>00209         CPTextFieldDOMInputElement.onblur = CPTextFieldBlurFunction;
<a name="l00210"></a>00210         
<a name="l00211"></a>00211         CPTextFieldDOMStandardInputElement = CPTextFieldDOMInputElement;
<a name="l00212"></a>00212     }
<a name="l00213"></a>00213     
<a name="l00214"></a>00214     <span class="keywordflow">if</span> (<a class="code" href="_c_p_compatibility_8j.html#a1fbfe7ca6b2cef354ecfe78f6cfd6659">CPFeatureIsCompatible</a>(<a class="code" href="_c_p_compatibility_8j.html#a0b91d410005c785703f56ed4351a438e">CPInputTypeCanBeChangedFeature</a>))
<a name="l00215"></a>00215     {
<a name="l00216"></a>00216         <span class="keywordflow">if</span> ([<span class="keyword">self</span> isSecure])
<a name="l00217"></a>00217             CPTextFieldDOMInputElement.type = <span class="stringliteral">&quot;password&quot;</span>;
<a name="l00218"></a>00218         <span class="keywordflow">else</span>
<a name="l00219"></a>00219             CPTextFieldDOMInputElement.type = <span class="stringliteral">&quot;text&quot;</span>;
<a name="l00220"></a>00220 
<a name="l00221"></a>00221         <span class="keywordflow">return</span> CPTextFieldDOMInputElement;
<a name="l00222"></a>00222     }
<a name="l00223"></a>00223 
<a name="l00224"></a>00224     <span class="keywordflow">if</span> ([<span class="keyword">self</span> isSecure])
<a name="l00225"></a>00225     {
<a name="l00226"></a>00226         <span class="keywordflow">if</span> (!CPTextFieldDOMPasswordInputElement)
<a name="l00227"></a>00227         {
<a name="l00228"></a>00228             CPTextFieldDOMPasswordInputElement = document.createElement(<span class="stringliteral">&quot;input&quot;</span>);
<a name="l00229"></a>00229             CPTextFieldDOMPasswordInputElement.style.position = <span class="stringliteral">&quot;absolute&quot;</span>;
<a name="l00230"></a>00230             CPTextFieldDOMPasswordInputElement.style.border = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00231"></a>00231             CPTextFieldDOMPasswordInputElement.style.padding = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00232"></a>00232             CPTextFieldDOMPasswordInputElement.style.margin = <span class="stringliteral">&quot;0px&quot;</span>;
<a name="l00233"></a>00233             CPTextFieldDOMPasswordInputElement.style.whiteSpace = <span class="stringliteral">&quot;pre&quot;</span>;
<a name="l00234"></a>00234             CPTextFieldDOMPasswordInputElement.style.background = <span class="stringliteral">&quot;transparent&quot;</span>;
<a name="l00235"></a>00235             CPTextFieldDOMPasswordInputElement.style.outline = <span class="stringliteral">&quot;none&quot;</span>;
<a name="l00236"></a>00236             CPTextFieldDOMPasswordInputElement.type = <span class="stringliteral">&quot;password&quot;</span>;
<a name="l00237"></a>00237 
<a name="l00238"></a>00238             CPTextFieldDOMPasswordInputElement.onblur = CPTextFieldBlurFunction;
<a name="l00239"></a>00239         }
<a name="l00240"></a>00240         
<a name="l00241"></a>00241         CPTextFieldDOMInputElement = CPTextFieldDOMPasswordInputElement;
<a name="l00242"></a>00242     }
<a name="l00243"></a>00243     <span class="keywordflow">else</span>
<a name="l00244"></a>00244     {
<a name="l00245"></a>00245         CPTextFieldDOMInputElement = CPTextFieldDOMStandardInputElement;
<a name="l00246"></a>00246     }
<a name="l00247"></a>00247     
<a name="l00248"></a>00248     <span class="keywordflow">return</span> CPTextFieldDOMInputElement;
<a name="l00249"></a>00249 }
<a name="l00250"></a>00250 <span class="preprocessor">#endif</span>
<a name="l00251"></a>00251 <span class="preprocessor"></span>
<a name="l00252"></a><a class="code" href="class_c_p_text_field.html#aee822bcc7c53f565f05cc25f72e7be5b">00252</a> - (id)initWithFrame:(CGRect)aFrame
<a name="l00253"></a>00253 {
<a name="l00254"></a>00254     <span class="keyword">self</span> = [<span class="keyword">super</span> initWithFrame:aFrame];
<a name="l00255"></a>00255 
<a name="l00256"></a>00256     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l00257"></a>00257     {
<a name="l00258"></a>00258         [<span class="keyword">self</span> setStringValue:@&quot;&quot;];
<a name="l00259"></a>00259         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a3da0a821aa41434e59383fc020f4208b">setPlaceholderString</a>:@&quot;&quot;];
<a name="l00260"></a>00260 
<a name="l00261"></a>00261         _sendActionOn = <a class="code" href="_c_p_event_8j.html#a00e117370b1d4dd6662eb83c4246e61a">CPKeyUpMask</a> | <a class="code" href="_c_p_event_8j.html#a0cb2d4bf26a5dcd356dbf102a37f316b">CPKeyDownMask</a>;
<a name="l00262"></a>00262 
<a name="l00263"></a>00263         [<span class="keyword">self</span> setValue:CPLeftTextAlignment forThemeAttribute:@&quot;alignment&quot;];
<a name="l00264"></a>00264     }
<a name="l00265"></a>00265     
<a name="l00266"></a>00266     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00267"></a>00267 }
<a name="l00268"></a>00268 
<a name="l00269"></a>00269 <span class="preprocessor">#pragma mark Controlling Editability and Selectability</span>
<a name="l00270"></a>00270 <span class="preprocessor"></span>
<a name="l00274"></a><a class="code" href="class_c_p_text_field.html#a074f65ecde05cdcec487476eaf99ee1c">00274</a> - (void)setEditable:(BOOL)shouldBeEditable
<a name="l00275"></a>00275 {
<a name="l00276"></a>00276     _isEditable = shouldBeEditable;
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278 
<a name="l00282"></a><a class="code" href="class_c_p_text_field.html#a1e2b51581d192251faa9a6900dcda64d">00282</a> - (BOOL)isEditable
<a name="l00283"></a>00283 {
<a name="l00284"></a>00284     <span class="keywordflow">return</span> _isEditable;
<a name="l00285"></a>00285 }
<a name="l00286"></a>00286 
<a name="l00291"></a><a class="code" href="class_c_p_text_field.html#a29e97c91c2249509c1ebe062daf0a157">00291</a> - (void)setSelectable:(BOOL)aFlag
<a name="l00292"></a>00292 {
<a name="l00293"></a>00293     _isSelectable = aFlag;
<a name="l00294"></a>00294 }
<a name="l00295"></a>00295 
<a name="l00299"></a><a class="code" href="class_c_p_text_field.html#a3f30f1a468f04f40871971bf9f16a203">00299</a> - (BOOL)isSelectable
<a name="l00300"></a>00300 {
<a name="l00301"></a>00301     <span class="keywordflow">return</span> _isSelectable;
<a name="l00302"></a>00302 }
<a name="l00303"></a>00303 
<a name="l00308"></a><a class="code" href="class_c_p_text_field.html#ac63bc5a2d5bcaf77f937e05831b989eb">00308</a> - (void)setSecure:(BOOL)aFlag
<a name="l00309"></a>00309 {
<a name="l00310"></a>00310     _isSecure = aFlag;
<a name="l00311"></a>00311 }
<a name="l00312"></a>00312 
<a name="l00316"></a><a class="code" href="class_c_p_text_field.html#aebf19194314e4af7d90ee01eae78280c">00316</a> - (BOOL)isSecure
<a name="l00317"></a>00317 {
<a name="l00318"></a>00318     <span class="keywordflow">return</span> _isSecure;
<a name="l00319"></a>00319 }
<a name="l00320"></a>00320 
<a name="l00321"></a>00321 <span class="comment">// Setting the Bezel Style</span>
<a name="l00326"></a><a class="code" href="class_c_p_text_field.html#a5fc3b5c748e61ff34853917f3bcdbdd0">00326</a> <span class="comment"></span>- (void)setBezeled:(BOOL)shouldBeBezeled
<a name="l00327"></a>00327 {
<a name="l00328"></a>00328     <span class="keywordflow">if</span> (shouldBeBezeled)
<a name="l00329"></a>00329         [<span class="keyword">self</span> setThemeState:CPThemeStateBezeled];
<a name="l00330"></a>00330     <span class="keywordflow">else</span>
<a name="l00331"></a>00331         [<span class="keyword">self</span> unsetThemeState:CPThemeStateBezeled];
<a name="l00332"></a>00332 }
<a name="l00333"></a>00333 
<a name="l00337"></a><a class="code" href="class_c_p_text_field.html#adaa55c9d360203b7c06d2fe035ab30ad">00337</a> - (BOOL)isBezeled
<a name="l00338"></a>00338 {
<a name="l00339"></a>00339     <span class="keywordflow">return</span> [<span class="keyword">self</span> hasThemeState:CPThemeStateBezeled];
<a name="l00340"></a>00340 }
<a name="l00341"></a>00341 
<a name="l00346"></a><a class="code" href="class_c_p_text_field.html#a5bcb37d07f30e9cf06ba9926b41e21eb">00346</a> - (void)setBezelStyle:(CPTextFieldBezelStyle)aBezelStyle
<a name="l00347"></a>00347 {
<a name="l00348"></a>00348     var shouldBeRounded = aBezelStyle === <a class="code" href="_c_p_text_field_8j.html#a50bacf57c023263265f5f1e7e681489d">CPTextFieldRoundedBezel</a>;
<a name="l00349"></a>00349     
<a name="l00350"></a>00350     <span class="keywordflow">if</span> (shouldBeRounded)
<a name="l00351"></a>00351         [<span class="keyword">self</span> setThemeState:CPTextFieldStateRounded];
<a name="l00352"></a>00352     <span class="keywordflow">else</span>
<a name="l00353"></a>00353         [<span class="keyword">self</span> unsetThemeState:CPTextFieldStateRounded];
<a name="l00354"></a>00354 }
<a name="l00355"></a>00355 
<a name="l00359"></a><a class="code" href="class_c_p_text_field.html#af8ac85a222d72ff09cf1b65f7690f74f">00359</a> - (CPTextFieldBezelStyle)bezelStyle
<a name="l00360"></a>00360 {
<a name="l00361"></a>00361     <span class="keywordflow">if</span> ([<span class="keyword">self</span> hasThemeState:<a class="code" href="_c_p_text_field_8j.html#a83312094a6f7f1255a156d27cc88a4a9">CPTextFieldStateRounded</a>])
<a name="l00362"></a>00362         <span class="keywordflow">return</span> <a class="code" href="_c_p_text_field_8j.html#a50bacf57c023263265f5f1e7e681489d">CPTextFieldRoundedBezel</a>;
<a name="l00363"></a>00363 
<a name="l00364"></a>00364     <span class="keywordflow">return</span> <a class="code" href="_c_p_text_field_8j.html#a0a4ebf79bcabaa98ab2adaad9ba4a7ec">CPTextFieldSquareBezel</a>;
<a name="l00365"></a>00365 }
<a name="l00366"></a>00366 
<a name="l00371"></a><a class="code" href="class_c_p_text_field.html#ae0191cd005c89a59d446066b63f22002">00371</a> - (void)setBordered:(BOOL)shouldBeBordered
<a name="l00372"></a>00372 {
<a name="l00373"></a>00373     <span class="keywordflow">if</span> (shouldBeBordered)
<a name="l00374"></a>00374         [<span class="keyword">self</span> setThemeState:CPThemeStateBordered];
<a name="l00375"></a>00375     <span class="keywordflow">else</span>
<a name="l00376"></a>00376         [<span class="keyword">self</span> unsetThemeState:CPThemeStateBordered];
<a name="l00377"></a>00377 }
<a name="l00378"></a>00378 
<a name="l00382"></a><a class="code" href="class_c_p_text_field.html#a08b87e5e5924d1b1137289eb29a264f9">00382</a> - (BOOL)isBordered
<a name="l00383"></a>00383 {
<a name="l00384"></a>00384     <span class="keywordflow">return</span> [<span class="keyword">self</span> hasThemeState:CPThemeStateBordered];
<a name="l00385"></a>00385 }
<a name="l00386"></a>00386 
<a name="l00391"></a><a class="code" href="class_c_p_text_field.html#aad11ed6d14ee4387a61ab08e4f91b509">00391</a> - (void)setDrawsBackground:(BOOL)shouldDrawBackground
<a name="l00392"></a>00392 {
<a name="l00393"></a>00393     <span class="keywordflow">if</span> (_drawsBackground == shouldDrawBackground)
<a name="l00394"></a>00394         <span class="keywordflow">return</span>;
<a name="l00395"></a>00395         
<a name="l00396"></a>00396     _drawsBackground = shouldDrawBackground;
<a name="l00397"></a>00397     
<a name="l00398"></a>00398     [<span class="keyword">self</span> setNeedsLayout];
<a name="l00399"></a>00399     [<span class="keyword">self</span> setNeedsDisplay:YES];
<a name="l00400"></a>00400 }
<a name="l00401"></a>00401 
<a name="l00405"></a><a class="code" href="class_c_p_text_field.html#a48e48305c966dc2147d895714d89a29d">00405</a> - (BOOL)drawsBackground
<a name="l00406"></a>00406 {
<a name="l00407"></a>00407     <span class="keywordflow">return</span> _drawsBackground;
<a name="l00408"></a>00408 }
<a name="l00409"></a>00409 
<a name="l00414"></a><a class="code" href="class_c_p_text_field.html#acbfe4cc69711826967adcbb6b66d46c9">00414</a> - (void)setTextFieldBackgroundColor:(<a class="code" href="class_c_p_color.html">CPColor</a>)aColor
<a name="l00415"></a>00415 {
<a name="l00416"></a>00416     <span class="keywordflow">if</span> (_textFieldBackgroundColor == aColor)
<a name="l00417"></a>00417         <span class="keywordflow">return</span>;
<a name="l00418"></a>00418         
<a name="l00419"></a>00419     _textFieldBackgroundColor = aColor;
<a name="l00420"></a>00420     
<a name="l00421"></a>00421     [<span class="keyword">self</span> setNeedsLayout];
<a name="l00422"></a>00422     [<span class="keyword">self</span> setNeedsDisplay:YES];
<a name="l00423"></a>00423 }
<a name="l00424"></a>00424 
<a name="l00428"></a><a class="code" href="class_c_p_text_field.html#aaec5d50a43594402c577fef4d1fa41da">00428</a> - (<a class="code" href="class_c_p_color.html">CPColor</a>)textFieldBackgroundColor
<a name="l00429"></a>00429 {
<a name="l00430"></a>00430     <span class="keywordflow">return</span> _textFieldBackgroundColor;
<a name="l00431"></a>00431 }
<a name="l00432"></a>00432 
<a name="l00433"></a>00433 <span class="comment">/* @ignore */</span>
<a name="l00434"></a><a class="code" href="class_c_p_text_field.html#a9cf8e6fa18aec8d3d52d9f1daeeebbba">00434</a> - (BOOL)acceptsFirstResponder
<a name="l00435"></a>00435 {
<a name="l00436"></a>00436     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a1e2b51581d192251faa9a6900dcda64d">isEditable</a>] &amp;&amp; [<span class="keyword">self</span> isEnabled];
<a name="l00437"></a>00437 }
<a name="l00438"></a>00438 
<a name="l00439"></a>00439 <span class="comment">/* @ignore */</span>
<a name="l00440"></a><a class="code" href="class_c_p_text_field.html#a377e73781d298f53f78e5248f7d4712f">00440</a> - (BOOL)becomeFirstResponder
<a name="l00441"></a>00441 {
<a name="l00442"></a>00442 <span class="preprocessor">#if PLATFORM(DOM)</span>
<a name="l00443"></a>00443 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (CPTextFieldInputOwner &amp;&amp; [CPTextFieldInputOwner window] !== [<span class="keyword">self</span> window])
<a name="l00444"></a>00444         [[CPTextFieldInputOwner window] makeFirstResponder:nil];
<a name="l00445"></a>00445 <span class="preprocessor">#endif</span>
<a name="l00446"></a>00446 <span class="preprocessor"></span>
<a name="l00447"></a>00447     [<span class="keyword">self</span> setThemeState:CPThemeStateEditing];
<a name="l00448"></a>00448 
<a name="l00449"></a>00449     [<span class="keyword">self</span> _updatePlaceholderState];
<a name="l00450"></a>00450 
<a name="l00451"></a>00451     [<span class="keyword">self</span> setNeedsLayout];
<a name="l00452"></a>00452 
<a name="l00453"></a>00453     _isEditing = NO;
<a name="l00454"></a>00454 
<a name="l00455"></a>00455 <span class="preprocessor">#if PLATFORM(DOM)</span>
<a name="l00456"></a>00456 <span class="preprocessor"></span>
<a name="l00457"></a>00457     var <span class="keywordtype">string</span> = [<span class="keyword">self</span> stringValue],
<a name="l00458"></a>00458         element = [<span class="keyword">self</span> _inputElement];
<a name="l00459"></a>00459 
<a name="l00460"></a>00460     element.value = string;
<a name="l00461"></a>00461     element.style.color = [[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;text-color&quot;] cssString];
<a name="l00462"></a>00462     element.style.font = [[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;font&quot;] cssString];
<a name="l00463"></a>00463     element.style.zIndex = 1000;
<a name="l00464"></a>00464 
<a name="l00465"></a>00465     <span class="keywordflow">switch</span> ([<span class="keyword">self</span> alignment])
<a name="l00466"></a>00466     {
<a name="l00467"></a>00467         <span class="keywordflow">case</span> <a class="code" href="_c_p_control_8j.html#a1a27f1ba54d9210fd64849b846de7929">CPCenterTextAlignment</a>: element.style.textAlign = <span class="stringliteral">&quot;center&quot;</span>;
<a name="l00468"></a>00468                                     <span class="keywordflow">break</span>;
<a name="l00469"></a>00469         <span class="keywordflow">case</span> <a class="code" href="_c_p_control_8j.html#a7f9bbcc35a65106771e5661b570e5158">CPRightTextAlignment</a>:  element.style.textAlign = <span class="stringliteral">&quot;right&quot;</span>;
<a name="l00470"></a>00470                                     <span class="keywordflow">break</span>;
<a name="l00471"></a>00471         <span class="keywordflow">default</span>:                    element.style.textAlign = <span class="stringliteral">&quot;left&quot;</span>;
<a name="l00472"></a>00472     }
<a name="l00473"></a>00473 
<a name="l00474"></a>00474     var contentRect = [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#abbb54f512bbb38c203287cbe44df36f0">contentRectForBounds</a>:[<span class="keyword">self</span> bounds]];
<a name="l00475"></a>00475 
<a name="l00476"></a>00476     element.style.top = _CGRectGetMinY(contentRect) + <span class="stringliteral">&quot;px&quot;</span>;
<a name="l00477"></a>00477     element.style.left = (_CGRectGetMinX(contentRect) - 1) + <span class="stringliteral">&quot;px&quot;</span>; <span class="comment">// why -1?</span>
<a name="l00478"></a>00478     element.style.width = _CGRectGetWidth(contentRect) + <span class="stringliteral">&quot;px&quot;</span>;
<a name="l00479"></a>00479     element.style.height = _CGRectGetHeight(contentRect) + <span class="stringliteral">&quot;px&quot;</span>;
<a name="l00480"></a>00480 
<a name="l00481"></a>00481     _DOMElement.appendChild(element);
<a name="l00482"></a>00482 
<a name="l00483"></a>00483     window.setTimeout(function() 
<a name="l00484"></a>00484     { 
<a name="l00485"></a>00485         element.focus();
<a name="l00486"></a>00486         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a6bf7dd92e0811f90ef7c543dc7864ff7">textDidFocus</a>:[<a class="code" href="class_c_p_notification.html" title="A notification that can be posted to a CPNotificationCenter.">CPNotification</a> <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">notificationWithName</a>:CPTextFieldDidFocusNotification <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">object</a>:self <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">userInfo</a>:nil]];
<a name="l00487"></a>00487         CPTextFieldInputOwner = <span class="keyword">self</span>;
<a name="l00488"></a>00488     }, 0.0);
<a name="l00489"></a>00489  
<a name="l00490"></a>00490     element.value = [<span class="keyword">self</span> stringValue];
<a name="l00491"></a>00491 
<a name="l00492"></a>00492     [[[<span class="keyword">self</span> window] platformWindow] _propagateCurrentDOMEvent:YES];
<a name="l00493"></a>00493     
<a name="l00494"></a>00494     CPTextFieldInputIsActive = YES;
<a name="l00495"></a>00495 
<a name="l00496"></a>00496     <span class="keywordflow">if</span> (document.attachEvent)
<a name="l00497"></a>00497     {
<a name="l00498"></a>00498         CPTextFieldCachedSelectStartFunction = [[<span class="keyword">self</span> window] platformWindow]._DOMBodyElement.onselectstart;
<a name="l00499"></a>00499         CPTextFieldCachedDragFunction = [[<span class="keyword">self</span> window] platformWindow]._DOMBodyElement.ondrag;
<a name="l00500"></a>00500         
<a name="l00501"></a>00501         [[<span class="keyword">self</span> window] platformWindow]._DOMBodyElement.ondrag = function () {};
<a name="l00502"></a>00502         [[<span class="keyword">self</span> window] platformWindow]._DOMBodyElement.onselectstart = function () {};
<a name="l00503"></a>00503     }
<a name="l00504"></a>00504 <span class="preprocessor">#endif</span>
<a name="l00505"></a>00505 <span class="preprocessor"></span>
<a name="l00506"></a>00506     <span class="keywordflow">return</span> YES;
<a name="l00507"></a>00507 }
<a name="l00508"></a>00508 
<a name="l00509"></a>00509 <span class="comment">/* @ignore */</span>
<a name="l00510"></a><a class="code" href="class_c_p_text_field.html#a21221c598961c5bd41b4d5c161777f08">00510</a> - (BOOL)resignFirstResponder
<a name="l00511"></a>00511 {
<a name="l00512"></a>00512     [<span class="keyword">self</span> unsetThemeState:CPThemeStateEditing];
<a name="l00513"></a>00513 
<a name="l00514"></a>00514     [<span class="keyword">self</span> _updatePlaceholderState];
<a name="l00515"></a>00515 
<a name="l00516"></a>00516     [<span class="keyword">self</span> setNeedsLayout];
<a name="l00517"></a>00517 
<a name="l00518"></a>00518 <span class="preprocessor">#if PLATFORM(DOM)</span>
<a name="l00519"></a>00519 <span class="preprocessor"></span>
<a name="l00520"></a>00520     var element = [<span class="keyword">self</span> _inputElement];
<a name="l00521"></a>00521 
<a name="l00522"></a>00522     [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a4e61e538ab0be1413e5f13cd39fa90ad">setObjectValue</a>:element.value];
<a name="l00523"></a>00523 
<a name="l00524"></a>00524     CPTextFieldInputResigning = YES;
<a name="l00525"></a>00525     element.blur();
<a name="l00526"></a>00526     
<a name="l00527"></a>00527     <span class="keywordflow">if</span> (!CPTextFieldInputDidBlur)
<a name="l00528"></a>00528         CPTextFieldBlurFunction();
<a name="l00529"></a>00529     
<a name="l00530"></a>00530     CPTextFieldInputDidBlur = NO;
<a name="l00531"></a>00531     CPTextFieldInputResigning = NO;
<a name="l00532"></a>00532 
<a name="l00533"></a>00533     <span class="keywordflow">if</span> (element.parentNode == _DOMElement)
<a name="l00534"></a>00534         element.parentNode.removeChild(element);
<a name="l00535"></a>00535 
<a name="l00536"></a>00536     CPTextFieldInputIsActive = NO;
<a name="l00537"></a>00537 
<a name="l00538"></a>00538     <span class="keywordflow">if</span> (document.attachEvent)
<a name="l00539"></a>00539     {
<a name="l00540"></a>00540         CPTextFieldCachedSelectStartFunction = nil;
<a name="l00541"></a>00541         CPTextFieldCachedDragFunction = nil;
<a name="l00542"></a>00542         
<a name="l00543"></a>00543         [[<span class="keyword">self</span> window] platformWindow]._DOMBodyElement.ondrag = CPTextFieldCachedDragFunction;
<a name="l00544"></a>00544         [[<span class="keyword">self</span> window] platformWindow]._DOMBodyElement.onselectstart = CPTextFieldCachedSelectStartFunction;
<a name="l00545"></a>00545     }
<a name="l00546"></a>00546     
<a name="l00547"></a>00547 <span class="preprocessor">#endif</span>
<a name="l00548"></a>00548 <span class="preprocessor"></span>
<a name="l00549"></a>00549     <span class="comment">//post CPControlTextDidEndEditingNotification</span>
<a name="l00550"></a>00550     <span class="keywordflow">if</span> (_isEditing)
<a name="l00551"></a>00551     {
<a name="l00552"></a>00552         _isEditing = NO;
<a name="l00553"></a>00553         [<span class="keyword">self</span> textDidEndEditing:[<a class="code" href="class_c_p_notification.html" title="A notification that can be posted to a CPNotificationCenter.">CPNotification</a> <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">notificationWithName</a>:CPControlTextDidEndEditingNotification <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">object</a>:self <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">userInfo</a>:nil]];
<a name="l00554"></a>00554 
<a name="l00555"></a>00555         <span class="keywordflow">if</span> ([<span class="keyword">self</span> sendsActionOnEndEditing])
<a name="l00556"></a>00556             [<span class="keyword">self</span> sendAction:[<span class="keyword">self</span> action] to:[<span class="keyword">self</span> target]];
<a name="l00557"></a>00557     }
<a name="l00558"></a>00558 
<a name="l00559"></a>00559     [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a134c2773497e142b28849daf5997cfea">textDidBlur</a>:[<a class="code" href="class_c_p_notification.html" title="A notification that can be posted to a CPNotificationCenter.">CPNotification</a> <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">notificationWithName</a>:CPTextFieldDidBlurNotification <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">object</a>:self <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">userInfo</a>:nil]];
<a name="l00560"></a>00560 
<a name="l00561"></a>00561     <span class="keywordflow">return</span> YES;
<a name="l00562"></a>00562 }
<a name="l00563"></a>00563 
<a name="l00567"></a><a class="code" href="class_c_p_text_field.html#a4c7c0fd1c2c4ae6706d8701152839480">00567</a> - (BOOL)needsPanelToBecomeKey
<a name="l00568"></a>00568 {
<a name="l00569"></a>00569     <span class="keywordflow">return</span> YES;
<a name="l00570"></a>00570 }
<a name="l00571"></a>00571 
<a name="l00572"></a><a class="code" href="class_c_p_text_field.html#addc903ae6c3dce9354867ab292b0fe17">00572</a> - (void)mouseDown:(<a class="code" href="class_c_p_event.html">CPEvent</a>)anEvent
<a name="l00573"></a>00573 {
<a name="l00574"></a>00574     <span class="comment">// Don&apos;t track! (ever?)</span>
<a name="l00575"></a>00575     <span class="keywordflow">if</span> ([<span class="keyword">self</span> isEditable] &amp;&amp; [<span class="keyword">self</span> isEnabled])
<a name="l00576"></a>00576         <span class="keywordflow">return</span> [[<span class="keyword">self</span> window] makeFirstResponder:self];
<a name="l00577"></a>00577     <span class="keywordflow">else</span>
<a name="l00578"></a>00578         <span class="keywordflow">return</span> [[<span class="keyword">self</span> nextResponder] mouseDown:anEvent];
<a name="l00579"></a>00579 }
<a name="l00580"></a>00580 
<a name="l00581"></a><a class="code" href="class_c_p_text_field.html#a996b68335f85314a21a4d2064cf1e522">00581</a> - (void)mouseUp:(<a class="code" href="class_c_p_event.html">CPEvent</a>)anEvent
<a name="l00582"></a>00582 {
<a name="l00583"></a>00583     <span class="keywordflow">if</span> (![<span class="keyword">self</span> isEditable] || ![<span class="keyword">self</span> isEnabled])
<a name="l00584"></a>00584         [[<span class="keyword">self</span> nextResponder] mouseUp:anEvent];
<a name="l00585"></a>00585 }
<a name="l00586"></a>00586 
<a name="l00587"></a><a class="code" href="class_c_p_text_field.html#a9b04b6e59988af3d04872b867564cc3c">00587</a> - (void)mouseDragged:(<a class="code" href="class_c_p_event.html">CPEvent</a>)anEvent
<a name="l00588"></a>00588 {
<a name="l00589"></a>00589     <span class="keywordflow">if</span> (![<span class="keyword">self</span> isEditable] || ![<span class="keyword">self</span> isEnabled])
<a name="l00590"></a>00590         [[<span class="keyword">self</span> nextResponder] mouseDragged:anEvent];
<a name="l00591"></a>00591 }
<a name="l00592"></a>00592 
<a name="l00593"></a><a class="code" href="class_c_p_text_field.html#acc14403b1db8eefe503ef7512bc83104">00593</a> - (void)keyUp:(<a class="code" href="class_c_p_event.html">CPEvent</a>)anEvent
<a name="l00594"></a>00594 {
<a name="l00595"></a>00595     var oldValue = [<span class="keyword">self</span> stringValue];
<a name="l00596"></a>00596     [<span class="keyword">self</span> _setStringValue:[<span class="keyword">self</span> _inputElement].value];
<a name="l00597"></a>00597 
<a name="l00598"></a>00598     <span class="keywordflow">if</span> (oldValue !== [<span class="keyword">self</span> stringValue])
<a name="l00599"></a>00599     {
<a name="l00600"></a>00600         <span class="keywordflow">if</span> (!_isEditing)
<a name="l00601"></a>00601         {
<a name="l00602"></a>00602             _isEditing = YES;
<a name="l00603"></a>00603             [<span class="keyword">self</span> textDidBeginEditing:[<a class="code" href="class_c_p_notification.html" title="A notification that can be posted to a CPNotificationCenter.">CPNotification</a> <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">notificationWithName</a>:CPControlTextDidBeginEditingNotification <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">object</a>:self <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">userInfo</a>:nil]];
<a name="l00604"></a>00604         }
<a name="l00605"></a>00605 
<a name="l00606"></a>00606         [<span class="keyword">self</span> textDidChange:[<a class="code" href="class_c_p_notification.html" title="A notification that can be posted to a CPNotificationCenter.">CPNotification</a> <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">notificationWithName</a>:CPControlTextDidChangeNotification <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">object</a>:self <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">userInfo</a>:nil]];
<a name="l00607"></a>00607     }
<a name="l00608"></a>00608 
<a name="l00609"></a>00609     [[[<span class="keyword">self</span> window] platformWindow] _propagateCurrentDOMEvent:YES];
<a name="l00610"></a>00610 }
<a name="l00611"></a>00611 
<a name="l00612"></a><a class="code" href="class_c_p_text_field.html#a84bb0a9f4d9342ed631a72d8cf536e76">00612</a> - (void)keyDown:(<a class="code" href="class_c_p_event.html">CPEvent</a>)anEvent
<a name="l00613"></a>00613 {
<a name="l00614"></a>00614     <span class="keywordflow">if</span> ([anEvent keyCode] === <a class="code" href="_c_p_responder_8j.html#a5809f8b1717b94d5316dd890220af494">CPReturnKeyCode</a>)
<a name="l00615"></a>00615     {
<a name="l00616"></a>00616         <span class="keywordflow">if</span> (_isEditing)
<a name="l00617"></a>00617         {
<a name="l00618"></a>00618             _isEditing = NO;
<a name="l00619"></a>00619             [<span class="keyword">self</span> textDidEndEditing:[<a class="code" href="class_c_p_notification.html" title="A notification that can be posted to a CPNotificationCenter.">CPNotification</a> <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">notificationWithName</a>:CPControlTextDidEndEditingNotification <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">object</a>:self <a class="code" href="class_c_p_notification.html#a03911b34d9b367606d5b0c0a4b1ea720">userInfo</a>:nil]];
<a name="l00620"></a>00620         }
<a name="l00621"></a>00621 
<a name="l00622"></a>00622         [<span class="keyword">self</span> sendAction:[<span class="keyword">self</span> action] to:[<span class="keyword">self</span> target]];
<a name="l00623"></a>00623         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#ab67c5ae4b907b48b49c4bf217986a136">selectText</a>:nil];
<a name="l00624"></a>00624 
<a name="l00625"></a>00625         [[[<span class="keyword">self</span> window] platformWindow] _propagateCurrentDOMEvent:NO];
<a name="l00626"></a>00626     }
<a name="l00627"></a>00627     <span class="keywordflow">else</span> <span class="keywordflow">if</span> ([anEvent keyCode] === <a class="code" href="_c_p_responder_8j.html#a850fba77f54879a5433ed17878f057cb">CPTabKeyCode</a>)
<a name="l00628"></a>00628     {
<a name="l00629"></a>00629         <span class="keywordflow">if</span> ([anEvent modifierFlags] &amp; <a class="code" href="_c_p_event_8j.html#a2343191b34b38dc1952bb44d83fa30d6">CPShiftKeyMask</a>)
<a name="l00630"></a>00630             [[<span class="keyword">self</span> window] selectPreviousKeyView:self];
<a name="l00631"></a>00631         <span class="keywordflow">else</span>
<a name="l00632"></a>00632             [[<span class="keyword">self</span> window] selectNextKeyView:self];
<a name="l00633"></a>00633 
<a name="l00634"></a>00634         <span class="keywordflow">if</span> ([[[<span class="keyword">self</span> window] firstResponder] respondsToSelector:<span class="keyword">@selector</span>(selectText:)])
<a name="l00635"></a>00635             [[[<span class="keyword">self</span> window] firstResponder] selectText:self];
<a name="l00636"></a>00636 
<a name="l00637"></a>00637         [[[<span class="keyword">self</span> window] platformWindow] _propagateCurrentDOMEvent:NO];
<a name="l00638"></a>00638     }
<a name="l00639"></a>00639     <span class="keywordflow">else</span>
<a name="l00640"></a>00640         [[[<span class="keyword">self</span> window] platformWindow] _propagateCurrentDOMEvent:YES];
<a name="l00641"></a>00641 
<a name="l00642"></a>00642     [[<a class="code" href="class_c_p_run_loop.html" title="The main run loop for the application.">CPRunLoop</a> <a class="code" href="class_c_p_run_loop.html#aba93f1cef957bad4353ce060981c0b9d">currentRunLoop</a>] <a class="code" href="class_c_p_run_loop.html#aad8e51e44d4c17634d8c45c1ca540217">limitDateForMode</a>:CPDefaultRunLoopMode];
<a name="l00643"></a>00643 }
<a name="l00644"></a>00644 
<a name="l00645"></a>00645 
<a name="l00646"></a><a class="code" href="class_c_p_text_field.html#a134c2773497e142b28849daf5997cfea">00646</a> - (void)textDidBlur:(<a class="code" href="class_c_p_notification.html" title="A notification that can be posted to a CPNotificationCenter.">CPNotification</a>)note
<a name="l00647"></a>00647 {
<a name="l00648"></a>00648     <span class="comment">//this looks to prevent false propagation of notifications for other objects</span>
<a name="l00649"></a>00649     <span class="keywordflow">if</span>([note <span class="keywordtype">object</span>] != <span class="keyword">self</span>)
<a name="l00650"></a>00650         <span class="keywordflow">return</span>;
<a name="l00651"></a>00651 
<a name="l00652"></a>00652     [[<a class="code" href="class_c_p_notification_center.html" title="Sends messages (CPNotification) between objects.">CPNotificationCenter</a> <a class="code" href="class_c_p_notification_center.html#a5abe725f1a1a48ac4cb1e45b6d9d50a8">defaultCenter</a>] <a class="code" href="class_c_p_notification_center.html#a2528b0b90f75d7263f9373d9cd896e94">postNotification</a>:note];
<a name="l00653"></a>00653 }
<a name="l00654"></a>00654 
<a name="l00655"></a><a class="code" href="class_c_p_text_field.html#a6bf7dd92e0811f90ef7c543dc7864ff7">00655</a> - (void)textDidFocus:(<a class="code" href="class_c_p_notification.html" title="A notification that can be posted to a CPNotificationCenter.">CPNotification</a>)note
<a name="l00656"></a>00656 {
<a name="l00657"></a>00657     <span class="comment">//this looks to prevent false propagation of notifications for other objects</span>
<a name="l00658"></a>00658     <span class="keywordflow">if</span>([note <span class="keywordtype">object</span>] != <span class="keyword">self</span>)
<a name="l00659"></a>00659         <span class="keywordflow">return</span>;
<a name="l00660"></a>00660 
<a name="l00661"></a>00661     [[<a class="code" href="class_c_p_notification_center.html" title="Sends messages (CPNotification) between objects.">CPNotificationCenter</a> <a class="code" href="class_c_p_notification_center.html#a5abe725f1a1a48ac4cb1e45b6d9d50a8">defaultCenter</a>] <a class="code" href="class_c_p_notification_center.html#a2528b0b90f75d7263f9373d9cd896e94">postNotification</a>:note];
<a name="l00662"></a>00662 }
<a name="l00663"></a>00663 
<a name="l00667"></a><a class="code" href="class_c_p_text_field.html#a422f78e4fcbf4895f02d818add3978ee">00667</a> - (id)objectValue
<a name="l00668"></a>00668 {
<a name="l00669"></a>00669     <span class="keywordflow">return</span> [<span class="keyword">super</span> objectValue];
<a name="l00670"></a>00670 }
<a name="l00671"></a>00671 
<a name="l00672"></a>00672 <span class="comment">/*</span>
<a name="l00673"></a>00673 <span class="comment">    @ignore</span>
<a name="l00674"></a>00674 <span class="comment">*/</span>
<a name="l00675"></a>00675 - (void)_setStringValue:(<span class="keywordtype">id</span>)aValue
<a name="l00676"></a>00676 {
<a name="l00677"></a>00677     [<span class="keyword">self</span> willChangeValueForKey:@&quot;objectValue&quot;];
<a name="l00678"></a>00678     [<span class="keyword">super</span> setObjectValue:String(aValue)];
<a name="l00679"></a>00679     [<span class="keyword">self</span> _updatePlaceholderState];
<a name="l00680"></a>00680     [<span class="keyword">self</span> didChangeValueForKey:@&quot;objectValue&quot;];
<a name="l00681"></a>00681 }
<a name="l00682"></a>00682 
<a name="l00683"></a><a class="code" href="class_c_p_text_field.html#a4e61e538ab0be1413e5f13cd39fa90ad">00683</a> - (void)setObjectValue:(<span class="keywordtype">id</span>)aValue
<a name="l00684"></a>00684 {
<a name="l00685"></a>00685     [<span class="keyword">super</span> setObjectValue:aValue];
<a name="l00686"></a>00686         
<a name="l00687"></a>00687 <span class="preprocessor">#if PLATFORM(DOM)</span>
<a name="l00688"></a>00688 <span class="preprocessor"></span>
<a name="l00689"></a>00689     <span class="keywordflow">if</span> (CPTextFieldInputOwner === <span class="keyword">self</span> || [[<span class="keyword">self</span> window] firstResponder] === <span class="keyword">self</span>)
<a name="l00690"></a>00690         [<span class="keyword">self</span> _inputElement].value = aValue;
<a name="l00691"></a>00691 <span class="preprocessor">#endif</span>
<a name="l00692"></a>00692 <span class="preprocessor"></span>
<a name="l00693"></a>00693     [<span class="keyword">self</span> _updatePlaceholderState];
<a name="l00694"></a>00694 }
<a name="l00695"></a>00695 
<a name="l00696"></a>00696 - (void)_updatePlaceholderState
<a name="l00697"></a>00697 {
<a name="l00698"></a>00698     var <span class="keywordtype">string</span> = [<span class="keyword">self</span> stringValue];
<a name="l00699"></a>00699 
<a name="l00700"></a>00700     <span class="keywordflow">if</span> ((!<span class="keywordtype">string</span> || <span class="keywordtype">string</span>.length === 0) &amp;&amp; ![<span class="keyword">self</span> hasThemeState:<a class="code" href="_c_p_theme_8j.html#acf168750fcd0e3bfc24c8c1f925a2a8e">CPThemeStateEditing</a>])
<a name="l00701"></a>00701         [<span class="keyword">self</span> setThemeState:CPTextFieldStatePlaceholder];
<a name="l00702"></a>00702     <span class="keywordflow">else</span>
<a name="l00703"></a>00703         [<span class="keyword">self</span> unsetThemeState:CPTextFieldStatePlaceholder];
<a name="l00704"></a>00704 }
<a name="l00705"></a>00705 
<a name="l00710"></a><a class="code" href="class_c_p_text_field.html#a3da0a821aa41434e59383fc020f4208b">00710</a> -(void)setPlaceholderString:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aStringValue
<a name="l00711"></a>00711 {
<a name="l00712"></a>00712     <span class="keywordflow">if</span> (_placeholderString === aStringValue)
<a name="l00713"></a>00713         <span class="keywordflow">return</span>;
<a name="l00714"></a>00714     
<a name="l00715"></a>00715     _placeholderString = aStringValue;
<a name="l00716"></a>00716 
<a name="l00717"></a>00717     <span class="comment">// Only update things if we need to show the placeholder</span>
<a name="l00718"></a>00718     <span class="keywordflow">if</span> ([<span class="keyword">self</span> hasThemeState:<a class="code" href="_c_p_text_field_8j.html#ace23af555767a4e15bdeb9ae1f86b5f4">CPTextFieldStatePlaceholder</a>])
<a name="l00719"></a>00719     {
<a name="l00720"></a>00720         [<span class="keyword">self</span> setNeedsLayout];
<a name="l00721"></a>00721         [<span class="keyword">self</span> setNeedsDisplay:YES];
<a name="l00722"></a>00722     }
<a name="l00723"></a>00723 }
<a name="l00724"></a>00724 
<a name="l00728"></a><a class="code" href="class_c_p_text_field.html#a70333a3ed2aea8b7ad8baf08269a751c">00728</a> - (<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)placeholderString
<a name="l00729"></a>00729 {
<a name="l00730"></a>00730     <span class="keywordflow">return</span> _placeholderString;
<a name="l00731"></a>00731 }
<a name="l00732"></a>00732 
<a name="l00750"></a><a class="code" href="class_c_p_text_field.html#ad9c9298dfb4c9d577d574a90735e9e90">00750</a> - (void)sizeToFit
<a name="l00751"></a>00751 {
<a name="l00752"></a>00752     var <a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a> = [([<span class="keyword">self</span> stringValue] || &quot; &quot;) sizeWithFont:[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;font&quot;]],
<a name="l00753"></a>00753         contentInset = [<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;content-inset&quot;],
<a name="l00754"></a>00754         minSize = [<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;min-size&quot;],
<a name="l00755"></a>00755         maxSize = [<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;max-size&quot;];
<a name="l00756"></a>00756 
<a name="l00757"></a>00757     <a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.width = <a class="code" href="_c_p_obj_j_runtime_8j.html#a45f5f88d061da0c18bcb6b6a854fe898">MAX</a>(<a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.width + contentInset.left + contentInset.right, minSize.width);
<a name="l00758"></a>00758     <a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.height = <a class="code" href="_c_p_obj_j_runtime_8j.html#a45f5f88d061da0c18bcb6b6a854fe898">MAX</a>(<a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.height + contentInset.top + contentInset.bottom, minSize.height);
<a name="l00759"></a>00759 
<a name="l00760"></a>00760     <span class="keywordflow">if</span> (maxSize.width &gt;= 0.0)
<a name="l00761"></a>00761         <a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.width = <a class="code" href="_c_p_obj_j_runtime_8j.html#a4fca277171215842609dc38a6f0c19fb">MIN</a>(<a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.width, maxSize.width);
<a name="l00762"></a>00762 
<a name="l00763"></a>00763     <span class="keywordflow">if</span> (maxSize.height &gt;= 0.0)
<a name="l00764"></a>00764         <a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.height = <a class="code" href="_c_p_obj_j_runtime_8j.html#a4fca277171215842609dc38a6f0c19fb">MIN</a>(<a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.height, maxSize.height);
<a name="l00765"></a>00765 
<a name="l00766"></a>00766     <span class="keywordflow">if</span> ([<span class="keyword">self</span> isEditable])
<a name="l00767"></a>00767         <a class="code" href="_c_p_screen_8j.html#ad241596b0d0f8cbdd1529d94ea71337b">size</a>.width = <a class="code" href="_c_g_geometry_8j.html#aa310af239f2108c573299b35776996fa">CGRectGetWidth</a>([<span class="keyword">self</span> <a class="code" href="_c_p_segmented_control_8j.html#a63fcc9e0dd97e8502cce685e88234e16">frame</a>]);
<a name="l00768"></a>00768 
<a name="l00769"></a>00769     [<span class="keyword">self</span> setFrameSize:size];
<a name="l00770"></a>00770 }
<a name="l00771"></a>00771 
<a name="l00775"></a><a class="code" href="class_c_p_text_field.html#ab67c5ae4b907b48b49c4bf217986a136">00775</a> - (void)selectText:(<span class="keywordtype">id</span>)sender
<a name="l00776"></a>00776 {
<a name="l00777"></a>00777 <span class="preprocessor">#if PLATFORM(DOM)</span>
<a name="l00778"></a>00778 <span class="preprocessor"></span>    var element = [<span class="keyword">self</span> _inputElement];
<a name="l00779"></a>00779     
<a name="l00780"></a>00780     <span class="keywordflow">if</span> (([<span class="keyword">self</span> isEditable] || [<span class="keyword">self</span> isSelectable]))
<a name="l00781"></a>00781     {
<a name="l00782"></a>00782         <span class="keywordflow">if</span> ([[<span class="keyword">self</span> window] firstResponder] === <span class="keyword">self</span>)
<a name="l00783"></a>00783             window.setTimeout(function() { element.select(); }, 0);
<a name="l00784"></a>00784         <span class="keywordflow">else</span>
<a name="l00785"></a>00785         {
<a name="l00786"></a>00786             [[<span class="keyword">self</span> window] makeFirstResponder:self];
<a name="l00787"></a>00787             window.setTimeout(function() {[<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#ab67c5ae4b907b48b49c4bf217986a136">selectText</a>:sender];}, 0);
<a name="l00788"></a>00788         }
<a name="l00789"></a>00789     }
<a name="l00790"></a>00790 <span class="preprocessor">#endif</span>
<a name="l00791"></a>00791 <span class="preprocessor"></span>}
<a name="l00792"></a>00792 
<a name="l00793"></a><a class="code" href="class_c_p_text_field.html#a853b68bc662ae703ed8b4a78c9c810bb">00793</a> - (void)copy:(<span class="keywordtype">id</span>)sender
<a name="l00794"></a>00794 {
<a name="l00795"></a>00795     <span class="keywordflow">if</span> (![<a class="code" href="class_c_p_platform.html">CPPlatform</a> isBrowser])
<a name="l00796"></a>00796     {
<a name="l00797"></a>00797         var selectedRange = [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a5153afb138eec90b25f8060e835f808b">selectedRange</a>];
<a name="l00798"></a>00798 
<a name="l00799"></a>00799         <span class="keywordflow">if</span> (selectedRange.length &lt; 1)
<a name="l00800"></a>00800             <span class="keywordflow">return</span>;
<a name="l00801"></a>00801 
<a name="l00802"></a>00802         var pasteboard = [<a class="code" href="class_c_p_pasteboard.html">CPPasteboard</a> <a class="code" href="class_c_p_pasteboard.html#a085d41e5f0d2c94888b0fab4647e07b8">generalPasteboard</a>],
<a name="l00803"></a>00803             stringValue = [<span class="keyword">self</span> stringValue],
<a name="l00804"></a>00804             stringForPasting = [stringValue substringWithRange:selectedRange];
<a name="l00805"></a>00805 
<a name="l00806"></a>00806         [pasteboard declareTypes:[CPStringPboardType] owner:nil];
<a name="l00807"></a>00807         [pasteboard setString:stringForPasting forType:CPStringPboardType];
<a name="l00808"></a>00808     }
<a name="l00809"></a>00809 }
<a name="l00810"></a>00810 
<a name="l00811"></a><a class="code" href="class_c_p_text_field.html#a885bfbc52cd77cc778ef8b02cd1d86fb">00811</a> - (void)cut:(<span class="keywordtype">id</span>)sender
<a name="l00812"></a>00812 {
<a name="l00813"></a>00813     <span class="keywordflow">if</span> (![<a class="code" href="class_c_p_platform.html">CPPlatform</a> isBrowser])
<a name="l00814"></a>00814     {
<a name="l00815"></a>00815         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a853b68bc662ae703ed8b4a78c9c810bb">copy</a>:sender];
<a name="l00816"></a>00816         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a7e8c0f69115ed982429d3ddce7fb3d59">deleteBackward</a>:sender];
<a name="l00817"></a>00817     }
<a name="l00818"></a>00818 }
<a name="l00819"></a>00819 
<a name="l00820"></a><a class="code" href="class_c_p_text_field.html#a858a7567973f8b59dc093af2801fa5a6">00820</a> - (void)paste:(<span class="keywordtype">id</span>)sender
<a name="l00821"></a>00821 {
<a name="l00822"></a>00822     <span class="keywordflow">if</span> (![<a class="code" href="class_c_p_platform.html">CPPlatform</a> isBrowser])
<a name="l00823"></a>00823     {
<a name="l00824"></a>00824         var pasteboard = [<a class="code" href="class_c_p_pasteboard.html">CPPasteboard</a> <a class="code" href="class_c_p_pasteboard.html#a085d41e5f0d2c94888b0fab4647e07b8">generalPasteboard</a>];
<a name="l00825"></a>00825 
<a name="l00826"></a>00826         <span class="keywordflow">if</span> (![[pasteboard types] containsObject:<a class="code" href="_c_p_pasteboard_8j.html#acd5614f9dbe81f6c200152e81093f22e">CPStringPboardType</a>])
<a name="l00827"></a>00827             <span class="keywordflow">return</span>;
<a name="l00828"></a>00828 
<a name="l00829"></a>00829         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a7e8c0f69115ed982429d3ddce7fb3d59">deleteBackward</a>:sender];
<a name="l00830"></a>00830 
<a name="l00831"></a>00831         var selectedRange = [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a5153afb138eec90b25f8060e835f808b">selectedRange</a>],
<a name="l00832"></a>00832             stringValue = [<span class="keyword">self</span> stringValue],
<a name="l00833"></a>00833             pasteString = [pasteboard stringForType:CPStringPboardType],
<a name="l00834"></a>00834             newValue = [stringValue stringByReplacingCharactersInRange:selectedRange withString:pasteString];
<a name="l00835"></a>00835 
<a name="l00836"></a>00836         [<span class="keyword">self</span> setStringValue:newValue];
<a name="l00837"></a>00837         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a377c01f28034e6f080a1782e43e159c6">setSelectedRange</a>:CPMakeRange(selectedRange.location+pasteString.length, 0)];
<a name="l00838"></a>00838     }
<a name="l00839"></a>00839 }
<a name="l00840"></a>00840 
<a name="l00841"></a><a class="code" href="class_c_p_text_field.html#a5153afb138eec90b25f8060e835f808b">00841</a> - (CPRange)selectedRange
<a name="l00842"></a>00842 {
<a name="l00843"></a>00843     <span class="keywordflow">if</span> ([[<span class="keyword">self</span> window] firstResponder] !== <span class="keyword">self</span>)
<a name="l00844"></a>00844         <span class="keywordflow">return</span> <a class="code" href="group__foundation.html#ga377fec0972facd19d72b8abcffcdb362">CPMakeRange</a>(0, 0);
<a name="l00845"></a>00845 
<a name="l00846"></a>00846     <span class="comment">// we wrap this in try catch because firefox will throw an exception in certain instances</span>
<a name="l00847"></a>00847     <span class="keywordflow">try</span> 
<a name="l00848"></a>00848     {
<a name="l00849"></a>00849         var inputElement = [<span class="keyword">self</span> _inputElement],
<a name="l00850"></a>00850             selectionStart = inputElement.selectionStart,
<a name="l00851"></a>00851             selectionEnd = inputElement.selectionEnd;
<a name="l00852"></a>00852 
<a name="l00853"></a>00853         <span class="keywordflow">if</span> ([selectionStart isKindOfClass:<a class="code" href="class_c_p_number.html" title="A bridged object to native Javascript numbers.">CPNumber</a>])
<a name="l00854"></a>00854             <span class="keywordflow">return</span> <a class="code" href="group__foundation.html#ga377fec0972facd19d72b8abcffcdb362">CPMakeRange</a>(selectionStart, selectionEnd - selectionStart);    
<a name="l00855"></a>00855 
<a name="l00856"></a>00856         <span class="comment">// browsers which don&apos;t support selectionStart/selectionEnd (aka IE).</span>
<a name="l00857"></a>00857         var theDocument = inputElement.ownerDocument || inputElement.document,
<a name="l00858"></a>00858             selectionRange = theDocument.selection.createRange(),
<a name="l00859"></a>00859             range = inputElement.createTextRange();
<a name="l00860"></a>00860 
<a name="l00861"></a>00861         <span class="keywordflow">if</span> (range.inRange(selectionRange))
<a name="l00862"></a>00862         {
<a name="l00863"></a>00863             range.setEndPoint(<span class="stringliteral">&apos;EndToStart&apos;</span>, selectionRange);
<a name="l00864"></a>00864             <span class="keywordflow">return</span> <a class="code" href="group__foundation.html#ga377fec0972facd19d72b8abcffcdb362">CPMakeRange</a>(range.text.length, selectionRange.text.length);
<a name="l00865"></a>00865         }
<a name="l00866"></a>00866     } 
<a name="l00867"></a>00867     <span class="keywordflow">catch</span> (e) 
<a name="l00868"></a>00868     {
<a name="l00869"></a>00869         <span class="comment">// fall through to the return</span>
<a name="l00870"></a>00870     }
<a name="l00871"></a>00871 
<a name="l00872"></a>00872     <span class="keywordflow">return</span> CGMakeRange(0, 0);
<a name="l00873"></a>00873 }
<a name="l00874"></a>00874 
<a name="l00875"></a><a class="code" href="class_c_p_text_field.html#a377c01f28034e6f080a1782e43e159c6">00875</a> - (void)setSelectedRange:(CPRange)aRange
<a name="l00876"></a>00876 {
<a name="l00877"></a>00877     <span class="keywordflow">if</span> (![[<span class="keyword">self</span> window] firstResponder] === <span class="keyword">self</span>)
<a name="l00878"></a>00878         <span class="keywordflow">return</span>;
<a name="l00879"></a>00879 
<a name="l00880"></a>00880     var inputElement = [<span class="keyword">self</span> _inputElement];
<a name="l00881"></a>00881 
<a name="l00882"></a>00882     <span class="keywordflow">try</span> 
<a name="l00883"></a>00883     {
<a name="l00884"></a>00884         <span class="keywordflow">if</span> ([inputElement.selectionStart isKindOfClass:<a class="code" href="class_c_p_number.html" title="A bridged object to native Javascript numbers.">CPNumber</a>])
<a name="l00885"></a>00885         {
<a name="l00886"></a>00886             inputElement.selectionStart = aRange.location;
<a name="l00887"></a>00887             inputElement.selectionEnd = <a class="code" href="group__foundation.html#ga9a9c6e53b2b0861cedbb77b5ab72e78f">CPMaxRange</a>(aRange);
<a name="l00888"></a>00888         }
<a name="l00889"></a>00889         <span class="keywordflow">else</span>
<a name="l00890"></a>00890         {
<a name="l00891"></a>00891             <span class="comment">// browsers which don&apos;t support selectionStart/selectionEnd (aka IE).</span>
<a name="l00892"></a>00892             var theDocument = inputElement.ownerDocument || inputElement.document,
<a name="l00893"></a>00893                 existingRange = theDocument.selection.createRange(),
<a name="l00894"></a>00894                 range = inputElement.createTextRange();
<a name="l00895"></a>00895     
<a name="l00896"></a>00896             <span class="keywordflow">if</span> (range.inRange(existingRange))
<a name="l00897"></a>00897             {
<a name="l00898"></a>00898                 range.collapse(<span class="keyword">true</span>);
<a name="l00899"></a>00899                 range.move(<span class="stringliteral">&apos;character&apos;</span>, aRange.location);
<a name="l00900"></a>00900                 range.moveEnd(<span class="stringliteral">&apos;character&apos;</span>, aRange.length);
<a name="l00901"></a>00901                 range.select();
<a name="l00902"></a>00902             }
<a name="l00903"></a>00903         }
<a name="l00904"></a>00904     }
<a name="l00905"></a>00905     <span class="keywordflow">catch</span> (e)
<a name="l00906"></a>00906     {
<a name="l00907"></a>00907     }
<a name="l00908"></a>00908 }
<a name="l00909"></a>00909 
<a name="l00910"></a><a class="code" href="class_c_p_text_field.html#abb8df615ff419f4c919066254975a6d3">00910</a> - (void)selectAll:(<span class="keywordtype">id</span>)sender
<a name="l00911"></a>00911 {
<a name="l00912"></a>00912     [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#ab67c5ae4b907b48b49c4bf217986a136">selectText</a>:sender];
<a name="l00913"></a>00913 }
<a name="l00914"></a>00914 
<a name="l00915"></a><a class="code" href="class_c_p_text_field.html#a7e8c0f69115ed982429d3ddce7fb3d59">00915</a> - (void)deleteBackward:(<span class="keywordtype">id</span>)sender
<a name="l00916"></a>00916 {
<a name="l00917"></a>00917     var selectedRange = [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a5153afb138eec90b25f8060e835f808b">selectedRange</a>],
<a name="l00918"></a>00918         stringValue = [<span class="keyword">self</span> stringValue],
<a name="l00919"></a>00919         newValue = [stringValue stringByReplacingCharactersInRange:selectedRange withString:&quot;&quot;];
<a name="l00920"></a>00920 
<a name="l00921"></a>00921     [<span class="keyword">self</span> setStringValue:newValue];
<a name="l00922"></a>00922     [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a377c01f28034e6f080a1782e43e159c6">setSelectedRange</a>:CPMakeRange(selectedRange.location, 0)];
<a name="l00923"></a>00923 }
<a name="l00924"></a>00924 
<a name="l00925"></a>00925 <span class="preprocessor">#pragma mark Setting the Delegate</span>
<a name="l00926"></a>00926 <span class="preprocessor"></span>
<a name="l00927"></a><a class="code" href="class_c_p_text_field.html#a257f162f4435a508b25a8f85abe44965">00927</a> - (void)setDelegate:(<span class="keywordtype">id</span>)aDelegate
<a name="l00928"></a>00928 {
<a name="l00929"></a>00929     var defaultCenter = [<a class="code" href="class_c_p_notification_center.html" title="Sends messages (CPNotification) between objects.">CPNotificationCenter</a> <a class="code" href="class_c_p_notification_center.html#a5abe725f1a1a48ac4cb1e45b6d9d50a8">defaultCenter</a>];
<a name="l00930"></a>00930     
<a name="l00931"></a>00931     <span class="comment">//unsubscribe the existing delegate if it exists</span>
<a name="l00932"></a>00932     <span class="keywordflow">if</span> (_delegate)
<a name="l00933"></a>00933     {
<a name="l00934"></a>00934         [defaultCenter removeObserver:_delegate name:CPControlTextDidBeginEditingNotification object:self];
<a name="l00935"></a>00935         [defaultCenter removeObserver:_delegate name:CPControlTextDidChangeNotification object:self];
<a name="l00936"></a>00936         [defaultCenter removeObserver:_delegate name:CPControlTextDidEndEditingNotification object:self];
<a name="l00937"></a>00937         [defaultCenter removeObserver:_delegate name:CPTextFieldDidFocusNotification object:self];
<a name="l00938"></a>00938         [defaultCenter removeObserver:_delegate name:CPTextFieldDidBlurNotification object:self];
<a name="l00939"></a>00939     }
<a name="l00940"></a>00940     
<a name="l00941"></a>00941     _delegate = aDelegate;
<a name="l00942"></a>00942     
<a name="l00943"></a>00943     <span class="keywordflow">if</span> ([_delegate respondsToSelector:<span class="keyword">@selector</span>(controlTextDidBeginEditing:)])
<a name="l00944"></a>00944         [defaultCenter
<a name="l00945"></a>00945             addObserver:_delegate
<a name="l00946"></a>00946                selector:@selector(controlTextDidBeginEditing:)
<a name="l00947"></a>00947                    name:CPControlTextDidBeginEditingNotification
<a name="l00948"></a>00948                  object:self];
<a name="l00949"></a>00949     
<a name="l00950"></a>00950     <span class="keywordflow">if</span> ([_delegate respondsToSelector:<span class="keyword">@selector</span>(controlTextDidChange:)])
<a name="l00951"></a>00951         [defaultCenter
<a name="l00952"></a>00952             addObserver:_delegate
<a name="l00953"></a>00953                selector:@selector(controlTextDidChange:)
<a name="l00954"></a>00954                    name:CPControlTextDidChangeNotification
<a name="l00955"></a>00955                  object:self];
<a name="l00956"></a>00956     
<a name="l00957"></a>00957     
<a name="l00958"></a>00958     <span class="keywordflow">if</span> ([_delegate respondsToSelector:<span class="keyword">@selector</span>(controlTextDidEndEditing:)])
<a name="l00959"></a>00959         [defaultCenter
<a name="l00960"></a>00960             addObserver:_delegate
<a name="l00961"></a>00961                selector:@selector(controlTextDidEndEditing:)
<a name="l00962"></a>00962                    name:CPControlTextDidEndEditingNotification
<a name="l00963"></a>00963                  object:self];
<a name="l00964"></a>00964 
<a name="l00965"></a>00965     <span class="keywordflow">if</span> ([_delegate respondsToSelector:<span class="keyword">@selector</span>(controlTextDidFocus:)])
<a name="l00966"></a>00966         [defaultCenter
<a name="l00967"></a>00967             addObserver:_delegate
<a name="l00968"></a>00968                selector:@selector(controlTextDidFocus:)
<a name="l00969"></a>00969                    name:CPTextFieldDidFocusNotification
<a name="l00970"></a>00970                  object:self];
<a name="l00971"></a>00971 
<a name="l00972"></a>00972     <span class="keywordflow">if</span> ([_delegate respondsToSelector:<span class="keyword">@selector</span>(controlTextDidBlur:)])
<a name="l00973"></a>00973         [defaultCenter
<a name="l00974"></a>00974             addObserver:_delegate
<a name="l00975"></a>00975                selector:@selector(controlTextDidBlur:)
<a name="l00976"></a>00976                    name:CPTextFieldDidBlurNotification
<a name="l00977"></a>00977                  object:self];
<a name="l00978"></a>00978 }
<a name="l00979"></a>00979 
<a name="l00980"></a><a class="code" href="class_c_p_text_field.html#a59d1934f3bd92cca645846e34cf3dc2b">00980</a> - (id)delegate
<a name="l00981"></a>00981 {
<a name="l00982"></a>00982     <span class="keywordflow">return</span> _delegate;
<a name="l00983"></a>00983 }
<a name="l00984"></a>00984 
<a name="l00985"></a><a class="code" href="class_c_p_text_field.html#abbb54f512bbb38c203287cbe44df36f0">00985</a> - (CGRect)contentRectForBounds:(CGRect)bounds
<a name="l00986"></a>00986 {
<a name="l00987"></a>00987     var contentInset = [<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;content-inset&quot;];
<a name="l00988"></a>00988     
<a name="l00989"></a>00989     <span class="keywordflow">if</span> (!contentInset)
<a name="l00990"></a>00990         <span class="keywordflow">return</span> bounds;
<a name="l00991"></a>00991     
<a name="l00992"></a>00992     bounds.origin.x += contentInset.left;
<a name="l00993"></a>00993     bounds.origin.y += contentInset.top;
<a name="l00994"></a>00994     bounds.size.width -= contentInset.left + contentInset.right;
<a name="l00995"></a>00995     bounds.size.height -= contentInset.top + contentInset.bottom;
<a name="l00996"></a>00996     
<a name="l00997"></a>00997     <span class="keywordflow">return</span> bounds;
<a name="l00998"></a>00998 }
<a name="l00999"></a>00999 
<a name="l01000"></a><a class="code" href="class_c_p_text_field.html#a4fc29e59d00bd404ddadfd09045ed0e4">01000</a> - (CGRect)bezelRectForBounds:(CFRect)bounds
<a name="l01001"></a>01001 {
<a name="l01002"></a>01002     var bezelInset = [<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;bezel-inset&quot;];
<a name="l01003"></a>01003 
<a name="l01004"></a>01004     <span class="keywordflow">if</span> (_CGInsetIsEmpty(bezelInset))
<a name="l01005"></a>01005         <span class="keywordflow">return</span> bounds;
<a name="l01006"></a>01006     
<a name="l01007"></a>01007     bounds.origin.x += bezelInset.left;
<a name="l01008"></a>01008     bounds.origin.y += bezelInset.top;
<a name="l01009"></a>01009     bounds.size.width -= bezelInset.left + bezelInset.right;
<a name="l01010"></a>01010     bounds.size.height -= bezelInset.top + bezelInset.bottom;
<a name="l01011"></a>01011     
<a name="l01012"></a>01012     <span class="keywordflow">return</span> bounds;
<a name="l01013"></a>01013 }
<a name="l01014"></a>01014 
<a name="l01015"></a><a class="code" href="class_c_p_text_field.html#a3268caa3292b8497b0d693b4f9ecf2f9">01015</a> - (CGRect)rectForEphemeralSubviewNamed:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aName
<a name="l01016"></a>01016 {
<a name="l01017"></a>01017     <span class="keywordflow">if</span> (aName === <span class="stringliteral">&quot;bezel-view&quot;</span>)
<a name="l01018"></a>01018         <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a4fc29e59d00bd404ddadfd09045ed0e4">bezelRectForBounds</a>:[<span class="keyword">self</span> bounds]];
<a name="l01019"></a>01019     
<a name="l01020"></a>01020     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (aName === <span class="stringliteral">&quot;content-view&quot;</span>)
<a name="l01021"></a>01021         <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#abbb54f512bbb38c203287cbe44df36f0">contentRectForBounds</a>:[<span class="keyword">self</span> bounds]];
<a name="l01022"></a>01022     
<a name="l01023"></a>01023     <span class="keywordflow">return</span> [<span class="keyword">super</span> rectForEphemeralSubviewNamed:aName];
<a name="l01024"></a>01024 }
<a name="l01025"></a>01025 
<a name="l01026"></a><a class="code" href="class_c_p_text_field.html#a6a007fbaa54065a5934c77ff681861e4">01026</a> - (<a class="code" href="class_c_p_view.html">CPView</a>)createEphemeralSubviewNamed:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aName
<a name="l01027"></a>01027 {
<a name="l01028"></a>01028     <span class="keywordflow">if</span> (aName === <span class="stringliteral">&quot;bezel-view&quot;</span>)
<a name="l01029"></a>01029     {
<a name="l01030"></a>01030         var view = [[<a class="code" href="class_c_p_view.html">CPView</a> alloc] initWithFrame:_CGRectMakeZero()];
<a name="l01031"></a>01031 
<a name="l01032"></a>01032         [view setHitTests:NO];
<a name="l01033"></a>01033         
<a name="l01034"></a>01034         <span class="keywordflow">return</span> view;
<a name="l01035"></a>01035     }
<a name="l01036"></a>01036     <span class="keywordflow">else</span>
<a name="l01037"></a>01037     {
<a name="l01038"></a>01038         var view = [[_CPImageAndTextView alloc] initWithFrame:_CGRectMakeZero()];
<a name="l01039"></a>01039         <span class="comment">//[view setImagePosition:CPNoImage];</span>
<a name="l01040"></a>01040         
<a name="l01041"></a>01041         [view setHitTests:NO];
<a name="l01042"></a>01042         
<a name="l01043"></a>01043         <span class="keywordflow">return</span> view;
<a name="l01044"></a>01044     }
<a name="l01045"></a>01045     
<a name="l01046"></a>01046     <span class="keywordflow">return</span> [<span class="keyword">super</span> createEphemeralSubviewNamed:aName];
<a name="l01047"></a>01047 }
<a name="l01048"></a>01048 
<a name="l01049"></a><a class="code" href="class_c_p_text_field.html#a28243b74054ecd1f7a66b2b34a887785">01049</a> - (void)layoutSubviews
<a name="l01050"></a>01050 {
<a name="l01051"></a>01051     var bezelView = [<span class="keyword">self</span> layoutEphemeralSubviewNamed:@&quot;bezel-view&quot;
<a name="l01052"></a>01052                                            positioned:CPWindowBelow
<a name="l01053"></a>01053                       relativeToEphemeralSubviewNamed:@&quot;content-view&quot;];
<a name="l01054"></a>01054       
<a name="l01055"></a>01055     <span class="keywordflow">if</span> (bezelView)
<a name="l01056"></a>01056         [bezelView setBackgroundColor:[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;bezel-color&quot;]];
<a name="l01057"></a>01057     
<a name="l01058"></a>01058     var contentView = [<span class="keyword">self</span> layoutEphemeralSubviewNamed:@&quot;content-view&quot;
<a name="l01059"></a>01059                                              positioned:CPWindowAbove
<a name="l01060"></a>01060                         relativeToEphemeralSubviewNamed:@&quot;bezel-view&quot;];
<a name="l01061"></a>01061 
<a name="l01062"></a>01062     <span class="keywordflow">if</span> (contentView)
<a name="l01063"></a>01063     {
<a name="l01064"></a>01064         [contentView setHidden:[<span class="keyword">self</span> hasThemeState:CPThemeStateEditing]];
<a name="l01065"></a>01065 
<a name="l01066"></a>01066         var <span class="keywordtype">string</span> = <span class="stringliteral">&quot;&quot;</span>;
<a name="l01067"></a>01067         
<a name="l01068"></a>01068         <span class="keywordflow">if</span> ([<span class="keyword">self</span> hasThemeState:<a class="code" href="_c_p_text_field_8j.html#ace23af555767a4e15bdeb9ae1f86b5f4">CPTextFieldStatePlaceholder</a>])
<a name="l01069"></a>01069             <span class="keywordtype">string</span> = [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a70333a3ed2aea8b7ad8baf08269a751c">placeholderString</a>];
<a name="l01070"></a>01070         <span class="keywordflow">else</span>
<a name="l01071"></a>01071         {
<a name="l01072"></a>01072             <span class="keywordtype">string</span> = [<span class="keyword">self</span> stringValue];
<a name="l01073"></a>01073 
<a name="l01074"></a>01074             <span class="keywordflow">if</span> ([<span class="keyword">self</span> isSecure])
<a name="l01075"></a>01075                 <span class="keywordtype">string</span> = <a class="code" href="_c_p_text_field_8j.html#a38dea2bda643ff60a88fce596e9cb064">secureStringForString</a>(<span class="keywordtype">string</span>);
<a name="l01076"></a>01076         }
<a name="l01077"></a>01077 
<a name="l01078"></a>01078         [contentView setText:string];
<a name="l01079"></a>01079 
<a name="l01080"></a>01080         [contentView setTextColor:[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;text-color&quot;]];
<a name="l01081"></a>01081         [contentView setFont:[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;font&quot;]];
<a name="l01082"></a>01082         [contentView setAlignment:[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;alignment&quot;]];
<a name="l01083"></a>01083         [contentView setVerticalAlignment:[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;vertical-alignment&quot;]];
<a name="l01084"></a>01084         [contentView setLineBreakMode:[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;line-break-mode&quot;]];
<a name="l01085"></a>01085         [contentView setTextShadowColor:[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;text-shadow-color&quot;]];
<a name="l01086"></a>01086         [contentView setTextShadowOffset:[<span class="keyword">self</span> currentValueForThemeAttribute:@&quot;text-shadow-offset&quot;]];
<a name="l01087"></a>01087     }
<a name="l01088"></a>01088 }
<a name="l01089"></a>01089 
<a name="l01090"></a>01090 <span class="keyword">@end</span>
<a name="l01091"></a>01091 
<a name="l01092"></a><a class="code" href="_c_p_text_field_8j.html#a38dea2bda643ff60a88fce596e9cb064">01092</a> var <a class="code" href="_c_p_text_field_8j.html#a38dea2bda643ff60a88fce596e9cb064">secureStringForString</a> = function(aString)
<a name="l01093"></a>01093 {
<a name="l01094"></a>01094     <span class="comment">// This is true for when aString === &quot;&quot; and null/undefined.</span>
<a name="l01095"></a>01095     <span class="keywordflow">if</span> (!aString)
<a name="l01096"></a>01096         <span class="keywordflow">return</span> <span class="stringliteral">&quot;&quot;</span>;
<a name="l01097"></a>01097 
<a name="l01098"></a>01098     <span class="keywordflow">return</span> Array(aString.length+1).join(<a class="code" href="_c_p_text_field_8j.html#a980528c034ab9ad8a4fe446d70394a5c">CPSecureTextFieldCharacter</a>);
<a name="l01099"></a>01099 }
<a name="l01100"></a>01100 
<a name="l01101"></a>01101 
<a name="l01102"></a>01102 var CPTextFieldIsEditableKey            = <span class="stringliteral">&quot;CPTextFieldIsEditableKey&quot;</span>,
<a name="l01103"></a><a class="code" href="_c_p_text_field_8j.html#a75dd4cf71fa94edf824baaa5a6bf408c">01103</a>     <a class="code" href="_c_p_text_field_8j.html#a75dd4cf71fa94edf824baaa5a6bf408c">CPTextFieldIsSelectableKey</a>          = <span class="stringliteral">&quot;CPTextFieldIsSelectableKey&quot;</span>,
<a name="l01104"></a><a class="code" href="_c_p_text_field_8j.html#a4c2eb9e0557ddf7f9c4cd4e07d2c17c8">01104</a>     <a class="code" href="_c_p_text_field_8j.html#a4c2eb9e0557ddf7f9c4cd4e07d2c17c8">CPTextFieldIsBorderedKey</a>            = <span class="stringliteral">&quot;CPTextFieldIsBorderedKey&quot;</span>,
<a name="l01105"></a><a class="code" href="_c_p_text_field_8j.html#a8c36c14dfda2f70ce2f65e27a7696df4">01105</a>     <a class="code" href="_c_p_text_field_8j.html#a8c36c14dfda2f70ce2f65e27a7696df4">CPTextFieldIsBezeledKey</a>             = <span class="stringliteral">&quot;CPTextFieldIsBezeledKey&quot;</span>,
<a name="l01106"></a><a class="code" href="_c_p_text_field_8j.html#afc00109c001c17251046c0e5a86e96f2">01106</a>     <a class="code" href="_c_p_text_field_8j.html#afc00109c001c17251046c0e5a86e96f2">CPTextFieldBezelStyleKey</a>            = <span class="stringliteral">&quot;CPTextFieldBezelStyleKey&quot;</span>,
<a name="l01107"></a><a class="code" href="_c_p_text_field_8j.html#af1e3f5a6aea1be5c29a3d7be4bb528a4">01107</a>     <a class="code" href="_c_p_text_field_8j.html#af1e3f5a6aea1be5c29a3d7be4bb528a4">CPTextFieldDrawsBackgroundKey</a>       = <span class="stringliteral">&quot;CPTextFieldDrawsBackgroundKey&quot;</span>,
<a name="l01108"></a><a class="code" href="_c_p_text_field_8j.html#ac6d8bb04140e0152fc5b9d857937728b">01108</a>     <a class="code" href="_c_p_text_field_8j.html#ac6d8bb04140e0152fc5b9d857937728b">CPTextFieldLineBreakModeKey</a>         = <span class="stringliteral">&quot;CPTextFieldLineBreakModeKey&quot;</span>,
<a name="l01109"></a><a class="code" href="_c_p_text_field_8j.html#a4dcb1d5c1218deb66015b64667d560e8">01109</a>     <a class="code" href="_c_p_text_field_8j.html#a4dcb1d5c1218deb66015b64667d560e8">CPTextFieldBackgroundColorKey</a>       = <span class="stringliteral">&quot;CPTextFieldBackgroundColorKey&quot;</span>,
<a name="l01110"></a><a class="code" href="_c_p_text_field_8j.html#adddc9a81ebb0fe95fe16902ca3c436f5">01110</a>     <a class="code" href="_c_p_text_field_8j.html#adddc9a81ebb0fe95fe16902ca3c436f5">CPTextFieldPlaceholderStringKey</a>     = <span class="stringliteral">&quot;CPTextFieldPlaceholderStringKey&quot;</span>;
<a name="l01111"></a>01111 
<a name="l01112"></a>01112 <span class="keyword">@implementation </span><a class="code" href="class_c_p_text_field.html">CPTextField</a> (CPCoding)
<a name="l01113"></a>01113 
<a name="l01119"></a><a class="code" href="class_c_p_text_field.html#ac3fa0d2d31ccdfa6ebdd74288b028667">01119</a> - (id)initWithCoder:(<a class="code" href="class_c_p_coder.html" title="Defines methods for use when archiving &amp;amp; restoring (enc/decoding).">CPCoder</a>)aCoder
<a name="l01120"></a>01120 {
<a name="l01121"></a>01121     <span class="keyword">self</span> = [<span class="keyword">super</span> initWithCoder:aCoder];
<a name="l01122"></a>01122     
<a name="l01123"></a>01123     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l01124"></a>01124     {
<a name="l01125"></a>01125         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a074f65ecde05cdcec487476eaf99ee1c">setEditable</a>:[aCoder decodeBoolForKey:CPTextFieldIsEditableKey]];
<a name="l01126"></a>01126         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a29e97c91c2249509c1ebe062daf0a157">setSelectable</a>:[aCoder decodeBoolForKey:CPTextFieldIsSelectableKey]];
<a name="l01127"></a>01127 
<a name="l01128"></a>01128         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#aad11ed6d14ee4387a61ab08e4f91b509">setDrawsBackground</a>:[aCoder decodeBoolForKey:CPTextFieldDrawsBackgroundKey]];
<a name="l01129"></a>01129 
<a name="l01130"></a>01130         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#acbfe4cc69711826967adcbb6b66d46c9">setTextFieldBackgroundColor</a>:[aCoder decodeObjectForKey:CPTextFieldBackgroundColorKey]];
<a name="l01131"></a>01131 
<a name="l01132"></a>01132         [<span class="keyword">self</span> <a class="code" href="class_c_p_text_field.html#a3da0a821aa41434e59383fc020f4208b">setPlaceholderString</a>:[aCoder decodeObjectForKey:CPTextFieldPlaceholderStringKey]];
<a name="l01133"></a>01133     }
<a name="l01134"></a>01134     
<a name="l01135"></a>01135     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l01136"></a>01136 }
<a name="l01137"></a>01137 
<a name="l01142"></a><a class="code" href="class_c_p_text_field.html#a3fb179cd8dd9024c5dad95fe2e8e5a93">01142</a> - (void)encodeWithCoder:(<a class="code" href="class_c_p_coder.html" title="Defines methods for use when archiving &amp;amp; restoring (enc/decoding).">CPCoder</a>)aCoder
<a name="l01143"></a>01143 {
<a name="l01144"></a>01144     [<span class="keyword">super</span> encodeWithCoder:aCoder];
<a name="l01145"></a>01145     
<a name="l01146"></a>01146     [aCoder encodeBool:_isEditable forKey:CPTextFieldIsEditableKey];
<a name="l01147"></a>01147     [aCoder encodeBool:_isSelectable forKey:CPTextFieldIsSelectableKey];
<a name="l01148"></a>01148     
<a name="l01149"></a>01149     [aCoder encodeBool:_drawsBackground forKey:CPTextFieldDrawsBackgroundKey];
<a name="l01150"></a>01150     
<a name="l01151"></a>01151     [aCoder encodeObject:_textFieldBackgroundColor forKey:CPTextFieldBackgroundColorKey];
<a name="l01152"></a>01152     
<a name="l01153"></a>01153     [aCoder encodeObject:_placeholderString forKey:CPTextFieldPlaceholderStringKey];
<a name="l01154"></a>01154 }
<a name="l01155"></a>01155 
<a name="l01156"></a>01156 <span class="keyword">@end</span>
<a name="l01157"></a>01157 
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Tue Apr 6 10:32:56 2010 for Cappuccino API by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>

<!-- Mirrored from cappuccino.org/learn/documentation/_c_p_text_field_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:31 GMT -->
</html>