def insertText_(self, content):
     if self.maxLength:
         oldText = self.textStorage().copy()
     NSTextView.insertText_(self, content)
     if self.maxLength and self.textStorage().length() > self.maxLength:
         self.textStorage().setAttributedString_(oldText)
         self.didChangeText()
예제 #2
0
 def insertText_(self, text):
     if self.maxLength:
         oldText = self.textStorage().copy()
     NSTextView.insertText_(self, text)
     if self.maxLength and self.textStorage().length() > self.maxLength:
         self.textStorage().setAttributedString_(oldText)
         self.didChangeText()
예제 #3
0
 def readSelectionFromPasteboard_type_(self, pboard, type):
     if self.maxLength:
         text = pboard.stringForType_(type)
         if text:
             if self.textStorage().length() - self.rangeForUserTextChange().length + len(text) > self.maxLength:
                 text = text.substringWithRange_(NSMakeRange(0, self.maxLength - (self.textStorage().length() - self.rangeForUserTextChange().length)))
             self.textStorage().replaceCharactersInRange_withString_(self.rangeForUserTextChange(), text)
             self.didChangeText()
             return True
         return False
     else:
         return NSTextView.readSelectionFromPasteboard_type_(self, pboard, type)
 def readSelectionFromPasteboard_type_(self, pboard, type):
     self.owner.textWasPasted = True
     if self.maxLength:
         content = pboard.stringForType_(type)
         if content:
             if self.textStorage().length() - self.rangeForUserTextChange(
             ).length + len(content) > self.maxLength:
                 content = content.substringWithRange_(
                     NSMakeRange(
                         0, self.maxLength -
                         (self.textStorage().length() -
                          self.rangeForUserTextChange().length)))
             self.textStorage().replaceCharactersInRange_withString_(
                 self.rangeForUserTextChange(), content)
             self.didChangeText()
             return True
         return False
     else:
         return NSTextView.readSelectionFromPasteboard_type_(
             self, pboard, type)
 def initWithRect_(self, rect):
     self = NSTextView.initWithRect_(self, rect)
     if self:
         pass
     return self
예제 #6
0
 def initWithRect_(self, rect):
     self = NSTextView.initWithRect_(self, rect)
     if self:
         pass
     return self