mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
pgui: Fix missing cursor when typing candidate
This commit is contained in:
parent
25f9d3ff13
commit
4ba3df7082
@ -41,7 +41,8 @@ PGEntry::
|
|||||||
PGEntry(const string &name) :
|
PGEntry(const string &name) :
|
||||||
PGItem(name),
|
PGItem(name),
|
||||||
_text(get_text_node()),
|
_text(get_text_node()),
|
||||||
_obscure_text(get_text_node())
|
_obscure_text(get_text_node()),
|
||||||
|
_candidate_text(get_text_node())
|
||||||
{
|
{
|
||||||
set_cull_callback();
|
set_cull_callback();
|
||||||
|
|
||||||
@ -103,6 +104,7 @@ PGEntry(const PGEntry ©) :
|
|||||||
PGItem(copy),
|
PGItem(copy),
|
||||||
_text(copy._text),
|
_text(copy._text),
|
||||||
_obscure_text(copy._obscure_text),
|
_obscure_text(copy._obscure_text),
|
||||||
|
_candidate_text(copy._candidate_text),
|
||||||
_cursor_position(copy._cursor_position),
|
_cursor_position(copy._cursor_position),
|
||||||
_cursor_visible(copy._cursor_visible),
|
_cursor_visible(copy._cursor_visible),
|
||||||
_candidate_highlight_start(copy._candidate_highlight_start),
|
_candidate_highlight_start(copy._candidate_highlight_start),
|
||||||
@ -813,9 +815,9 @@ update_text() {
|
|||||||
cseq += wstring(1, (wchar_t)text_pop_properties_key);
|
cseq += wstring(1, (wchar_t)text_pop_properties_key);
|
||||||
|
|
||||||
// Create a special TextAssembler to insert the candidate string.
|
// Create a special TextAssembler to insert the candidate string.
|
||||||
TextAssembler ctext(_text);
|
_candidate_text = _text;
|
||||||
ctext.set_wsubstr(cseq, _cursor_position, 0);
|
_candidate_text.set_wsubstr(cseq, _cursor_position, 0);
|
||||||
assembled = ctext.assemble_text();
|
assembled = _candidate_text.assemble_text();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_current_text.is_empty()) {
|
if (!_current_text.is_empty()) {
|
||||||
@ -897,7 +899,8 @@ update_cursor() {
|
|||||||
_obscure_text.calc_r_c(row, column, _cursor_position);
|
_obscure_text.calc_r_c(row, column, _cursor_position);
|
||||||
xpos = _obscure_text.get_xpos(row, column);
|
xpos = _obscure_text.get_xpos(row, column);
|
||||||
ypos = _obscure_text.get_ypos(row, column);
|
ypos = _obscure_text.get_ypos(row, column);
|
||||||
} else {
|
}
|
||||||
|
else if (_candidate_wtext.empty()) {
|
||||||
_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') {
|
if (_cursor_position > 0 && _text.get_character(_cursor_position - 1) == '\n') {
|
||||||
row += 1;
|
row += 1;
|
||||||
@ -906,6 +909,11 @@ update_cursor() {
|
|||||||
xpos = _text.get_xpos(row, column);
|
xpos = _text.get_xpos(row, column);
|
||||||
ypos = _text.get_ypos(row, column);
|
ypos = _text.get_ypos(row, column);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
_candidate_text.calc_r_c(row, column, _cursor_position + (int)_candidate_cursor_pos);
|
||||||
|
xpos = _candidate_text.get_xpos(row, column);
|
||||||
|
ypos = _candidate_text.get_ypos(row, column);
|
||||||
|
}
|
||||||
|
|
||||||
_cursor_def.set_pos(xpos - _current_padding, 0.0f, ypos);
|
_cursor_def.set_pos(xpos - _current_padding, 0.0f, ypos);
|
||||||
_cursor_stale = false;
|
_cursor_stale = false;
|
||||||
@ -914,7 +922,7 @@ update_cursor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Should the cursor be visible?
|
// Should the cursor be visible?
|
||||||
if (!get_focus() || !_candidate_wtext.empty()) {
|
if (!get_focus()) {
|
||||||
show_hide_cursor(false);
|
show_hide_cursor(false);
|
||||||
} else {
|
} else {
|
||||||
double elapsed_time =
|
double elapsed_time =
|
||||||
|
@ -149,6 +149,7 @@ private:
|
|||||||
|
|
||||||
TextAssembler _text;
|
TextAssembler _text;
|
||||||
TextAssembler _obscure_text;
|
TextAssembler _obscure_text;
|
||||||
|
TextAssembler _candidate_text;
|
||||||
int _cursor_position;
|
int _cursor_position;
|
||||||
bool _cursor_stale;
|
bool _cursor_stale;
|
||||||
bool _cursor_visible;
|
bool _cursor_visible;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user