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

Fix TextEdit.get_rect_at_line_column returning negative pos even though cursor is in viewable area of the control #81354

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

MJacred
Copy link
Contributor

@MJacred MJacred commented Sep 5, 2023

Sister PR of #81352 (for Godot 3.x)

When both are merged, #81349 can be closed

Production edit: Fixes #81349

Before fix:

textedit-bug_godot-4.webm

After fix:

after.webm

@MJacred MJacred changed the title [4.x] Fix TextEdit.get_rect_at_line_column returning negative pos even though cursor is in viewable area of the control [4.x] Fix TextEdit.get_rect_at_line_column returning negative pos even though cursor is in viewable area of the control Sep 5, 2023
@AThousandShips AThousandShips added this to the 4.x milestone Sep 5, 2023
@MJacred MJacred marked this pull request as ready for review September 5, 2023 18:40
@MJacred MJacred requested a review from a team as a code owner September 5, 2023 18:40
@MJacred
Copy link
Contributor Author

MJacred commented Sep 5, 2023

@AThousandShips: done, ready for review

Copy link
Member

@Paulb23 Paulb23 left a comment

Choose a reason for hiding this comment

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

Changes look okay to me, would be good to add a unit test to capture this behaviour

@MJacred
Copy link
Contributor Author

MJacred commented Sep 10, 2023

EDIT: aaah! because get_pos_at_line_column returns bottom side of the line (totally forgot)


I would do it, but this does not make any sense in my head: if you drag the mouse from column 1 to 7 you should get his is. But apparently you even land in line 1, not 0... Similar confusion with other uses of get_pos_at_line_column in test_text_edit.h

text_edit->set_text("this is some text\nfor selection");
text_edit->grab_focus();
MessageQueue::get_singleton()->flush();

SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 1), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE);
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_pos_at_line_column(0, 7), MouseButtonMask::LEFT, Key::NONE);
CHECK(text_edit->has_selection());
CHECK(text_edit->get_selected_text() == "for s");

@MJacred MJacred requested a review from a team as a code owner September 10, 2023 19:37
@MJacred MJacred force-pushed the textedit_pixel_pos_fix branch 3 times, most recently from 46e56db to f3d37a3 Compare September 10, 2023 21:55
@MJacred MJacred closed this Sep 11, 2023
Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

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

Style looks good!

…gh cursor is in viewable area of the control
@akien-mga akien-mga changed the title [4.x] Fix TextEdit.get_rect_at_line_column returning negative pos even though cursor is in viewable area of the control Fix TextEdit.get_rect_at_line_column returning negative pos even though cursor is in viewable area of the control Sep 12, 2023
@akien-mga akien-mga modified the milestones: 4.x, 4.2 Sep 12, 2023
@akien-mga akien-mga merged commit 77623d0 into godotengine:master Sep 18, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@MJacred MJacred deleted the textedit_pixel_pos_fix branch September 18, 2023 18:59
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.

TextEdit.get_rect_at_line_column returns negative pos even though cursor is in viewable area of the control
4 participants