UITextField+CCUITextInput.mm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /****************************************************************************
  2. Copyright (c) 2015 Mazyad Alabduljaleel
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #import "ui/UIEditBox/iOS/UITextField+CCUITextInput.h"
  21. @implementation UITextField (CCUITextInput)
  22. - (NSString *)ccui_text
  23. {
  24. return self.text;
  25. }
  26. - (void)ccui_setText:(NSString *)ccui_text
  27. {
  28. self.text = ccui_text;
  29. }
  30. - (NSString *)ccui_placeholder
  31. {
  32. return self.placeholder;
  33. }
  34. - (void)ccui_setPlaceholder:(NSString *)ccui_placeholder
  35. {
  36. self.placeholder = ccui_placeholder;
  37. }
  38. - (UIColor *)ccui_textColor
  39. {
  40. return self.textColor;
  41. }
  42. - (void)ccui_setTextColor:(UIColor *)ccui_textColor
  43. {
  44. self.textColor = ccui_textColor;
  45. }
  46. - (UIFont *)ccui_font
  47. {
  48. return self.font;
  49. }
  50. - (void)ccui_setFont:(UIFont *)ccui_font
  51. {
  52. self.font = ccui_font;
  53. }
  54. - (NSTextAlignment)ccui_alignment
  55. {
  56. return self.textAlignment;
  57. }
  58. - (void)ccui_setTextHorizontalAlignment:(NSTextAlignment)ccui_alignment
  59. {
  60. self.textAlignment = ccui_alignment;
  61. }
  62. - (UIColor *)ccui_placeholderTextColor
  63. {
  64. SEL selector = @selector(placeholderTextColor);
  65. if ([self respondsToSelector:selector]) {
  66. return [self performSelector:selector];
  67. }
  68. return nil;
  69. }
  70. - (void)ccui_setPlaceholderTextColor:(UIColor *)ccui_placeholderTextColor
  71. {
  72. SEL selector = @selector(setPlaceholderTextColor:);
  73. if ([self respondsToSelector:selector]) {
  74. [self performSelector:selector withObject:ccui_placeholderTextColor];
  75. }
  76. }
  77. - (UIFont *)ccui_placeholderFont
  78. {
  79. SEL selector = @selector(placeholderFont);
  80. if ([self respondsToSelector:selector]) {
  81. return [self performSelector:selector];
  82. }
  83. return nil;
  84. }
  85. - (void)ccui_setPlaceholderFont:(UIFont *)ccui_placeholderFont
  86. {
  87. SEL selector = @selector(setPlaceholderFont:);
  88. if ([self respondsToSelector:selector]) {
  89. [self performSelector:selector withObject:ccui_placeholderFont];
  90. }
  91. }
  92. - (BOOL)ccui_secureTextEntry
  93. {
  94. return self.secureTextEntry;
  95. }
  96. - (void)ccui_setSecureTextEntry:(BOOL)ccui_secureTextEntry
  97. {
  98. self.secureTextEntry = ccui_secureTextEntry;
  99. }
  100. - (void)ccui_setDelegate:(id<UITextFieldDelegate,UITextViewDelegate>)delegate
  101. {
  102. self.delegate = delegate;
  103. }
  104. @end
  105. void LoadUITextFieldCCUITextInputCategory() {
  106. // noop
  107. }