mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
dgui: fix DirectEntry._autoCapitalize() on Python 3.x (#628)
This commit is contained in:
parent
43a5719bac
commit
5c99cf16f8
@ -216,11 +216,11 @@ class DirectEntry(DirectFrame):
|
||||
self._autoCapitalize()
|
||||
|
||||
def _autoCapitalize(self):
|
||||
name = self.get().decode('utf-8')
|
||||
name = self.guiItem.getWtext()
|
||||
# capitalize each word, allowing for things like McMutton
|
||||
capName = ''
|
||||
capName = u''
|
||||
# track each individual word to detect prefixes like Mc
|
||||
wordSoFar = ''
|
||||
wordSoFar = u''
|
||||
# track whether the previous character was part of a word or not
|
||||
wasNonWordChar = True
|
||||
for i, character in enumerate(name):
|
||||
@ -229,9 +229,9 @@ class DirectEntry(DirectFrame):
|
||||
# This assumes that string.lower and string.upper will return different
|
||||
# values for all unicode letters.
|
||||
# - Don't count apostrophes as a break between words
|
||||
if character.lower() == character.upper() and character != "'":
|
||||
if character.lower() == character.upper() and character != u"'":
|
||||
# we are between words
|
||||
wordSoFar = ''
|
||||
wordSoFar = u''
|
||||
wasNonWordChar = True
|
||||
else:
|
||||
capitalize = False
|
||||
@ -255,7 +255,8 @@ class DirectEntry(DirectFrame):
|
||||
wordSoFar += character
|
||||
wasNonWordChar = False
|
||||
capName += character
|
||||
self.enterText(capName.encode('utf-8'))
|
||||
self.guiItem.setWtext(capName)
|
||||
self.guiItem.setCursorPosition(self.guiItem.getNumCharacters())
|
||||
|
||||
def focusOutCommandFunc(self):
|
||||
if self['focusOutCommand']:
|
||||
|
Loading…
x
Reference in New Issue
Block a user