Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineEdit: Now double click to select a word, and triple click to sele… #46524

Merged
merged 1 commit into from
Mar 4, 2021

Conversation

kuruk-mm
Copy link
Contributor

@kuruk-mm kuruk-mm commented Feb 28, 2021

…ct all the content

Fix #46259

I used the code from TextEdit to make this one.

@kuruk-mm kuruk-mm requested a review from a team as a code owner February 28, 2021 19:54
Comment on lines 272 to 280
bool symbol = beg < text.length() && is_symbol(text[beg]);

while (beg > 0 && text[beg - 1] > 32 && (symbol == is_symbol(text[beg - 1]))) {
beg--;
}
while (end < text.length() && text[end + 1] > 32 && (symbol == is_symbol(text[end + 1]))) {
end++;
}
if (end < text.length()) {
end += 1;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use Vector<Vector2i> words = TS->shaped_text_get_word_breaks(text_rid); instead of is_symbol and > 32 to correctly detect words in the languages which do not use spaces, see _move_cursor_left, _move_cursor_right functions for example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the current approach is fine for 3.2 version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I will update this PR doing that on LineEdit and TextEdit and open a new PR with this code for 3.2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Calinou Calinou added bug cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:gui labels Feb 28, 2021
@Calinou Calinou added this to the 4.0 milestone Feb 28, 2021
@bruvzg bruvzg removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Mar 1, 2021
…ct all the content using the new TextServer

TextEdit: Update the method to search words with the new TextServer
@akien-mga akien-mga merged commit dd1881a into godotengine:master Mar 4, 2021
@akien-mga
Copy link
Member

Thanks!

@kuruk-mm kuruk-mm deleted the lineedit_triple_click branch March 4, 2021 15:15
@christinoleo
Copy link
Contributor

@kuruk-mm Thanks for the contribution!
I noticed that due to commit 06ae77a the method "shaped_text_get_word_breaks" now breaks on underscores (aka _ ), which means that a doubleclick on the editor window on a variable with_underscores_like_this will only select part of it (word by word split by the underscores) instead of the whole variable. Is this intended with your commit? I did some patch on my local godot to be able to select the entire variable name for myself and just want to know if this is something I should open an issue or PR about.. Thanks!

@groud
Copy link
Member

groud commented Apr 6, 2021

I noticed that due to commit 06ae77a the method "shaped_text_get_word_breaks" now breaks on underscores (aka _ ), which means that a doubleclick on the editor window on a variable with_underscores_like_this will only select part of it (word by word split by the underscores) instead of the whole variable.

Ah yeah, I had the same issue. This is quite annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double/triple click in LineEdit not working as expected
6 participants