UITextView+CCUITextInput.mm 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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/UITextView+CCUITextInput.h"
  21. @implementation UITextView (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. SEL selector = @selector(placeholder);
  33. if ([self respondsToSelector:selector]) {
  34. return [self performSelector:selector];
  35. }
  36. return nil;
  37. }
  38. - (void)ccui_setPlaceholder:(NSString *)ccui_placeholder
  39. {
  40. SEL selector = @selector(setPlaceholder:);
  41. if ([self respondsToSelector:selector]) {
  42. [self performSelector:selector withObject:ccui_placeholder];
  43. }
  44. }
  45. - (UIColor *)ccui_textColor
  46. {
  47. return self.textColor;
  48. }
  49. - (void)ccui_setTextColor:(UIColor *)ccui_textColor
  50. {
  51. self.textColor = ccui_textColor;
  52. }
  53. - (UIFont *)ccui_font
  54. {
  55. return self.font;
  56. }
  57. - (void)ccui_setFont:(UIFont *)ccui_font
  58. {
  59. self.font = ccui_font;
  60. }
  61. - (NSTextAlignment)ccui_alignment
  62. {
  63. return self.textAlignment;
  64. }
  65. - (void)ccui_setTextHorizontalAlignment:(NSTextAlignment)ccui_alignment
  66. {
  67. self.textAlignment = ccui_alignment;
  68. }
  69. - (UIColor *)ccui_placeholderTextColor
  70. {
  71. SEL selector = @selector(placeHolderLabel);
  72. if ([self respondsToSelector:selector]) {
  73. return ((UILabel *)[self performSelector:selector]).textColor;
  74. }
  75. return nil;
  76. }
  77. - (void)ccui_setPlaceholderTextColor:(UIColor *)ccui_placeholderTextColor
  78. {
  79. SEL selector = @selector(placeHolderLabel);
  80. if ([self respondsToSelector:selector]) {
  81. ((UILabel *)[self performSelector:selector]).textColor = ccui_placeholderTextColor;
  82. }
  83. }
  84. - (UIFont *)ccui_placeholderFont
  85. {
  86. SEL selector = @selector(placeHolderLabel);
  87. if ([self respondsToSelector:selector]) {
  88. return ((UILabel *)[self performSelector:selector]).font;
  89. }
  90. return nil;
  91. }
  92. - (void)ccui_setPlaceholderFont:(UIFont *)ccui_placeholderFont
  93. {
  94. SEL selector = @selector(placeHolderLabel);
  95. if ([self respondsToSelector:selector]) {
  96. ((UILabel *)[self performSelector:selector]).font = ccui_placeholderFont;
  97. }
  98. }
  99. - (BOOL)ccui_secureTextEntry
  100. {
  101. return self.secureTextEntry;
  102. }
  103. - (void)ccui_setSecureTextEntry:(BOOL)ccui_secureTextEntry
  104. {
  105. self.secureTextEntry = ccui_secureTextEntry;
  106. }
  107. - (void)ccui_setDelegate:(id<UITextFieldDelegate,UITextViewDelegate>)delegate
  108. {
  109. self.delegate = delegate;
  110. }
  111. @end
  112. void LoadUITextViewCCUITextInputCategory() {
  113. }