mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -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()
|
self._autoCapitalize()
|
||||||
|
|
||||||
def _autoCapitalize(self):
|
def _autoCapitalize(self):
|
||||||
name = self.get().decode('utf-8')
|
name = self.guiItem.getWtext()
|
||||||
# capitalize each word, allowing for things like McMutton
|
# capitalize each word, allowing for things like McMutton
|
||||||
capName = ''
|
capName = u''
|
||||||
# track each individual word to detect prefixes like Mc
|
# track each individual word to detect prefixes like Mc
|
||||||
wordSoFar = ''
|
wordSoFar = u''
|
||||||
# track whether the previous character was part of a word or not
|
# track whether the previous character was part of a word or not
|
||||||
wasNonWordChar = True
|
wasNonWordChar = True
|
||||||
for i, character in enumerate(name):
|
for i, character in enumerate(name):
|
||||||
@ -229,9 +229,9 @@ class DirectEntry(DirectFrame):
|
|||||||
# This assumes that string.lower and string.upper will return different
|
# This assumes that string.lower and string.upper will return different
|
||||||
# values for all unicode letters.
|
# values for all unicode letters.
|
||||||
# - Don't count apostrophes as a break between words
|
# - 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
|
# we are between words
|
||||||
wordSoFar = ''
|
wordSoFar = u''
|
||||||
wasNonWordChar = True
|
wasNonWordChar = True
|
||||||
else:
|
else:
|
||||||
capitalize = False
|
capitalize = False
|
||||||
@ -255,7 +255,8 @@ class DirectEntry(DirectFrame):
|
|||||||
wordSoFar += character
|
wordSoFar += character
|
||||||
wasNonWordChar = False
|
wasNonWordChar = False
|
||||||
capName += character
|
capName += character
|
||||||
self.enterText(capName.encode('utf-8'))
|
self.guiItem.setWtext(capName)
|
||||||
|
self.guiItem.setCursorPosition(self.guiItem.getNumCharacters())
|
||||||
|
|
||||||
def focusOutCommandFunc(self):
|
def focusOutCommandFunc(self):
|
||||||
if self['focusOutCommand']:
|
if self['focusOutCommand']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user