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

[#4876] Add support for modifier keys during drag operations #4879

Open
wants to merge 1 commit into
base: 4.2.x
Choose a base branch
from

Conversation

arbron
Copy link
Collaborator

@arbron arbron commented Dec 14, 2024

Adds the ability to use the OS-defined modifier key (usually Alt on Windows and Option on Mac) to toggle between the default drop behavior and the opposite behavior. So if dragging within the same actor this changes from the default move behaior to copy behavior and the opposite when dragging between different actors or to the sidebar.

Enabling this required access to the current drag payload during the ondragover event, so this extends the DragDrop class provided by core to store that information during the ondragstart event and adds a new handler for the ondragend event to clear the stored payload.

Currently this only covers dragging items, with some minor improvements to dragging favorites on the character sheet. This framework could be expanded in the future to support dragging actors into the bastion tab as well as dragging active effects, advancements, or activities.

Closes #4876

Adds the ability to use the OS-defined modifier key (usually
Alt on Windows and Option on Mac) to toggle between the default
drop behavior and the opposite behavior. So if dragging within
the same actor this changes from the default move behaior to
copy behavior and the opposite when dragging between different
actors or to the sidebar.

Enabling this required access to the current drag payload during
the `ondragover` event, so this extends the `DragDrop` class
provided by core to store that information during the `ondragstart`
event and adds a new handler for the `ondragend` event to clear
the stored payload.

Currently this only covers dragging items, with some minor
improvements to dragging favorites on the character sheet.
This framework could be expanded in the future to support
dragging actors into the bastion tab as well as dragging active
effects, advancements, or activities.

Closes #4876
@arbron arbron added the ux User experience related features or bugs label Dec 14, 2024
@arbron arbron added this to the D&D5E 4.2.0 milestone Dec 14, 2024
@arbron arbron requested a review from Fyorl December 14, 2024 00:58
@arbron arbron self-assigned this Dec 14, 2024
Copy link
Contributor

@Fyorl Fyorl left a comment

Choose a reason for hiding this comment

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

Just some high-level comments before I do a full review: I think it would be preferable to have fixed modifier keys that map to a specific action, rather than a key that toggles to the opposite of the default action. For example, holding Ctrl should always copy, and holding Shift should always move (doesn't have to be those exact modifiers), regardless of what the default action is.

@arbron
Copy link
Collaborator Author

arbron commented Dec 16, 2024

Just some high-level comments before I do a full review: I think it would be preferable to have fixed modifier keys that map to a specific action, rather than a key that toggles to the opposite of the default action. For example, holding Ctrl should always copy, and holding Shift should always move (doesn't have to be those exact modifiers), regardless of what the default action is.

Hmm, the thing I like about this approach is it takes advantage of the keys people already use with their operating system, so nothing new to learn (it also keeps the cursor updated so it is always clear what action will be performed).

@Fyorl
Copy link
Contributor

Fyorl commented Dec 16, 2024

Hmm, the thing I like about this approach is it takes advantage of the keys people already use with their operating system, so nothing new to learn (it also keeps the cursor updated so it is always clear what action will be performed).

Not sure what you mean. Ctrl is copy and Shift is move in Windows. Alt is create link. So holding Alt to switch between move or copy depending on what the default action is would be new behaviour.

@unsoluble
Copy link

Option-drag is always "duplicate" on macOS; there are no other OS-wide drag modifiers here. For what it's worth :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ux User experience related features or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add keyboard shortcuts that control whether a drag/drop operation is move or copy
3 participants