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

Snaps drop data to cursor when within +/- 3 columns and same line #31415

Closed

Conversation

codecustard
Copy link
Contributor

@codecustard codecustard commented Aug 16, 2019

Closes: #28472

@KoBeWi
Copy link
Member

KoBeWi commented Aug 16, 2019

Instead of editor setting, wouldn't it be better if it was done with a modifier key, like Shift or Control?

@codecustard
Copy link
Contributor Author

Yeah, possibly.

@akien-mga akien-mga added this to the 3.2 milestone Aug 17, 2019
@akien-mga
Copy link
Member

Hm, more settings nobody will ever know about... I think most users don't even know that they can drag and drop files to the script editor to get their path, so customizing what should happen then is a step further...

IMO we should just pick which behavior is the most expected one and keep only that.

@codecustard
Copy link
Contributor Author

If were not gonna have an option, reverting it back to cursor and not mouse position in my opinion seems to make better sense because you really need that precision and if you miss it by even 1 character it's a big deal.

@groud
Copy link
Member

groud commented Aug 17, 2019

No having this as an option is a bad idea IMHO. This would be another setting for something that is not relevant that much.

Having the drop at mouse position is the most expected behavior. If the dropping on a specific position is difficult, we should find a way to dynamically snap the dropping position to the positions that make more sense. (it might include the cursor's position)

@KoBeWi KoBeWi mentioned this pull request Aug 17, 2019
@Calinou
Copy link
Member

Calinou commented Aug 17, 2019

@groud We could use the cursor position only if the mouse position is close enough from the cursor (say, 50 * EDSCALE pixels) 🙂

@groud
Copy link
Member

groud commented Aug 17, 2019

Yeah, that would be a good idea. ^^

@akien-mga
Copy link
Member

We could use the cursor position only if the mouse position is close enough from the cursor (say, 50 * EDSCALE pixels)

That sounds good, as long as there's visual feedback to the user that the position is being snapped, so that it doesn't appear random.

@akien-mga
Copy link
Member

@sparkart Are you able to update the PR to implement #31415 (comment) ?

@codecustard
Copy link
Contributor Author

codecustard commented Aug 24, 2019

I have been busy with the start of the new semester. Right now I've updated the PR to address the originating issue of being difficult to drag with precision (e.g. between parenthesis) by checking if the mouse is on the same line as the cursor and is within +/- 3 columns.

Without visual feedback snapping to the cursor with a larger difference between the cursor and mouse of something like 50 pixels would indeed seem rather random.

If anyone is interested in adding that feel free, if not... I'll definitely update the PR to address #31415 (comment) when I have the time.

Adds a setting for the text editor that allows you to drop data at the mouse position or the cursor position.
@@ -1473,6 +1473,8 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
int row, col;
te->_get_mouse_pos(p_point, row, col);

bool dropAtCursor = (col <= te->cursor_get_column() + 3 && col >= te->cursor_get_column() - 3 && row == te->cursor_get_line()) ? true : false;
Copy link
Member

Choose a reason for hiding this comment

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

We use snake_case for identifiers.

Copy link
Member

Choose a reason for hiding this comment

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

A comment explaining why we do this ±3 would also be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After more testing, and thinking about it more.... I honestly don't think it's a good idea. It feels like it works nicely when you have the knowledge of how it is supposed to work, but if you don't know that it's based on the cursor position it might feel like a bug. For me it feels like one or the other is more intuitive. Drag at mouse position feels fine. Drag at cursor feels fine, too. But if you drag at cursor, only when the mouse is near the cursor it doesn't feel right because if you're gonna position the cursor at a certain spot, you should be able to drag anywhere on the editor and not be forced to be specifically within the range of the cursor. For example, what if you're typing along and the cursor is at the end of the line... then you try dragging between the parenthesis, which is at the end of the line, too... it'll position at the very end of the line and not betweeen the parenthesis and since you don't even know that it's based on the cursor, it feels clunky.

As you said before, if there are visible cues that it snaps to the cursor, it probably would make more sense. Until then, I think this small fix more confusing. I felt like this fix would be a better alternative until implementing that, but it's worse than if we had an option for drag at cursor or at mouse position. The modifier key might actually make more sense, but then we run in to the same argument of extra key settings.

Copy link
Member

@Calinou Calinou Sep 17, 2019

Choose a reason for hiding this comment

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

@codecustard Does it feel better to use if you decrease the tolerance to 1 or 2 characters (from 3)?

@akien-mga
Copy link
Member

Seems good apart from a couple style issues. The commit log should also be amended to properly describe what the commit now does.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Ok to merge pending style fixes.

@codecustard codecustard changed the title Adds setting for Dropping Data to Cursor/Mouse Position Snaps drop data to cursor when within +/- 3 columns and same line Sep 3, 2019
@name-here
Copy link

Another option (visually) would be to have the dragged file not snap to the cursor, but instead have the cursor follow the mouse to show exactly where it will be inserted. After dropping the file (path), the text cursor could stay at the end of the inserted text, and the script area could be active (it looks like the file area ends up active currently). Also, making the mouse cursor into a pointer instead of a hand when dragging over the script area would make it even easier to position precisely.

@akien-mga akien-mga modified the milestones: 3.2, 4.0 Nov 7, 2019
@aaronfranke
Copy link
Member

@codecustard Is this still desired? If so, it needs to be rebased on the latest master branch. While there are no conflicts, rebasing is important so that reviewers can easily test the PR.

If not, abandoned pull requests will be closed in the future as announced here.

@akien-mga
Copy link
Member

Closing as it still needs some changes, and from the last comments it was not clear if the final implementation was actually a good improvement. Might need some more testing/discussion to figure out how to have the best UX for this operation.

@Mickeon
Copy link
Contributor

Mickeon commented Sep 13, 2022

While this has not been "salvaged", the current behaviour on master supersedes it by a mile: the caret follows the cursor when it is carrying drop data.
Image

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.

Script Editor file drop at Cursor instead Mouse location
8 participants