mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 20:17:59 +00:00
Fixing a bug where clicking to the right of a character in a textbox...
...may select an invalid character, thus leading to a string out-of-bounds error when another character is entered. Enabled accented characters in textboxes, for Latin-1 charset.
This commit is contained in:
parent
8690dfdfe3
commit
7b147faf57
@ -198,7 +198,7 @@ void textbox::handle_event(const SDL_Event& event)
|
||||
int pos = 0;
|
||||
int distance = x;
|
||||
|
||||
for(int i = 1; i <= char_pos_.size(); ++i) {
|
||||
for(int i = 1; i < char_pos_.size(); ++i) {
|
||||
// Check individually each distance (if, one day, we support
|
||||
// RTL languages, char_pos[c] may not be monotonous.)
|
||||
if(abs(x - char_pos_[i]) < distance) {
|
||||
@ -276,9 +276,13 @@ void textbox::handle_event(const SDL_Event& event)
|
||||
}
|
||||
}
|
||||
|
||||
const char character = static_cast<char>(key.unicode);
|
||||
// const char character = static_cast<char>(key.unicode);
|
||||
int character = key.unicode;
|
||||
|
||||
if(isgraph(character) || character == ' ') {
|
||||
if(character != 0)
|
||||
std::cerr << "Char: " << character << "\n";
|
||||
|
||||
if(/*isgraph(character) || character == ' '*/ character >= 32 && character != 127) {
|
||||
changed = true;
|
||||
if(is_selection())
|
||||
erase_selection();
|
||||
|
Loading…
x
Reference in New Issue
Block a user