mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
Cursor after newline character appears on beginning of next line.
DirectEntry.updateNumLines updates text geom. DirectEntry API less inadequate. Closes #257
This commit is contained in:
parent
84915073e1
commit
78377ca10c
@ -302,12 +302,18 @@ class DirectEntry(DirectFrame):
|
|||||||
else:
|
else:
|
||||||
return self.guiItem.getText()
|
return self.guiItem.getText()
|
||||||
|
|
||||||
|
def getCursorPosition(self):
|
||||||
|
return self.guiItem.getCursorPosition()
|
||||||
|
|
||||||
def setCursorPosition(self, pos):
|
def setCursorPosition(self, pos):
|
||||||
if (pos < 0):
|
if (pos < 0):
|
||||||
self.guiItem.setCursorPosition(self.guiItem.getNumCharacters() + pos)
|
self.guiItem.setCursorPosition(self.guiItem.getNumCharacters() + pos)
|
||||||
else:
|
else:
|
||||||
self.guiItem.setCursorPosition(pos)
|
self.guiItem.setCursorPosition(pos)
|
||||||
|
|
||||||
|
def getNumCharacters(self):
|
||||||
|
return self.guiItem.getNumCharacters()
|
||||||
|
|
||||||
def enterText(self, text):
|
def enterText(self, text):
|
||||||
""" sets the entry's text, and moves the cursor to the end """
|
""" sets the entry's text, and moves the cursor to the end """
|
||||||
self.set(text)
|
self.set(text)
|
||||||
|
@ -208,6 +208,7 @@ set_num_lines(int num_lines) {
|
|||||||
nassertv(num_lines >= 1);
|
nassertv(num_lines >= 1);
|
||||||
_num_lines = num_lines;
|
_num_lines = num_lines;
|
||||||
_text_geom_stale = true;
|
_text_geom_stale = true;
|
||||||
|
update_text();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -864,6 +864,10 @@ update_cursor() {
|
|||||||
ypos = _obscure_text.get_ypos(row, column);
|
ypos = _obscure_text.get_ypos(row, column);
|
||||||
} else {
|
} else {
|
||||||
_text.calc_r_c(row, column, _cursor_position);
|
_text.calc_r_c(row, column, _cursor_position);
|
||||||
|
if (_cursor_position > 0 && _text.get_character(_cursor_position - 1) == '\n') {
|
||||||
|
row += 1;
|
||||||
|
column = 0;
|
||||||
|
}
|
||||||
xpos = _text.get_xpos(row, column);
|
xpos = _text.get_xpos(row, column);
|
||||||
ypos = _text.get_ypos(row, column);
|
ypos = _text.get_ypos(row, column);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user