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

The shortcut [Space + Left Mouse Button] have a bug. How to use [Ctrl + Left Mouse Button] instead of [Space + Left Mouse Button] to drag map? #3672

Closed
ankisme opened this issue Apr 23, 2023 · 8 comments
Labels
feature It's a feature, not a bug.

Comments

@ankisme
Copy link

ankisme commented Apr 23, 2023

Is your feature request related to a problem? Please describe.
Current shorcut of dragging map [Space + Left Mouse Button] is hardly to use for me, because when I pressed the space key, it always do the wrong thing, such as toggle the visible of current layer, then I have to mouse click on the map to change focus.

The way to reproduce it:

  1. mouse click on label of other layer, for example, the layer name is [layer ABC]
  2. pressing [Space + Left Mouse Button]
  3. then you will toggle the visible of [layer ABC]

And the space key is not easy to press for me, because it’s a big and long key on the keyboard. For me, the space key is convient to click once, but is not convient for pressing.

And I also don't want [middle mouse button], because the [middle mouse button] is convient for scroll, but is not convient for click.

Describe the solution you'd like
So I want to use [Ctrl + Left Mouse Button] instead of [Space + Left Mouse Button].

And I could not found any way to do this.

Here is my .ts extension script.

/// <reference types="@mapeditor/tiled-api" />

/* global tiled */

const dragLayer = tiled.registerAction("DragLayer", function (/* action */) {
	tiled.alert(`My desired shortcut is pressing [Ctrl + Left Mounse Button] to drag map,

	but current shortcut is pressing [Space + Left Mouse Button], and how to do it?`)
})
dragLayer.text = "DragLayer"
dragLayer.shortcut = "Space"

tiled.extendMenu("Layer", [
	{ action: "DragLayer", before: "SelectPreviousLayer" },
])

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

@ankisme ankisme added the feature It's a feature, not a bug. label Apr 23, 2023
@ankisme ankisme changed the title How to use [Ctrl + Left Mouse Button] instead of [Space + Left Mouse Button] to drag map? The shortcut [Space + Left Mouse Button] have a bug. How to use [Ctrl + Left Mouse Button] instead of [Space + Left Mouse Button] to drag map? Apr 23, 2023
@ankisme
Copy link
Author

ankisme commented Apr 24, 2023

I use autohotkey and mapping F1 key to Middle Mouse Button, now it's more convient, though it's still not the best.

@ankisme ankisme closed this as completed Apr 24, 2023
@ankisme
Copy link
Author

ankisme commented Apr 24, 2023

Finally I use AutoHotKey to solve the problem, now I can use [Ctrl+LeftMouseButon] to dragging and also [Ctrl+Mouse Wheel] to zoom in and zoom out.

I think it is much more better than [Space+LeftMouseButon] and [Ctrl+Mouse Wheel], and it also could fix the bug.

Here is the AutoHotKey script

#IfWinActive ahk_exe tiled.exe
~LCtrl::
KeyWait, LButton, Down
SendInput , {Space Down}
KeyWait, LCtrl, U
SendInput , {Space Up}
return
#IfWinActive

@bjorn
Copy link
Member

bjorn commented Apr 24, 2023

In general it would be nice to make mouse interaction customizable, but it is a lot more tricky than keyboard interaction due to the potential for conflicts. The Ctrl modifier is used by several tools in combination with Left Click, for example:

  • Ctrl toggles wheel behavior between zooming or scrolling
  • Ctrl+Shift with Left Click is used by Stamp Brush to draw circles
  • Ctrl with Left Click is used by tile selection tools to choose "Subtract" from current selection
  • Ctrl or Shift can be used with Left Click by object selection tool to add to selected objects, instead of replace
  • Ctrl with Left Click is used by Terrain Brush to toggle the mode (change corner / change tile)
  • Ctrl with Left Click is used by object selection tool when resizing and when rotating, for keeping aspect ratio and snap angle

So when making Ctrl + Left Click perform panning, care would need to be taken not to break any of the existing interactions. Using a different key, like Space, or a different mouse button, like Middle Mouse Button, avoids all these conflicts.

I do see the issue with toggling layer visibility, and I think maybe this could be improved by making the currently focused area more visible. As part of writing a new style (see #3597), I would like to make sure the focus is always clearly visible also for the views like layer list, tileset and map views.

@ankisme
Copy link
Author

ankisme commented Apr 24, 2023

Now I know [Ctrl] is used by many tools, and [Ctrl+Left Click] may conflict other tools in some mode.

Now it seems that the more clearly way is to forbid the functionality of toggle visible by [Space] key, because the [Space] key will conflict with [Space + Left Click] when focus on layer label.

Maybe [V] key is better than [Space] key for toggle visible of current layer, because [V] is the first character of [Visible].

@bjorn
Copy link
Member

bjorn commented Apr 24, 2023

Now it seems that the more clearly way is to forbid the functionality of toggle visible by [Space] key, because the [Space] key will conflict with [Space + Left Click] when focus on layer label.

Maybe [V] key is better than [Space] key for toggle visible of current layer, because [V] is the first character of [Visible].

Yeah, actually Space for toggling layer visibility is a historical thing that was added back in 0de0f20 (Tiled 1.1.4) because some people had grown used to it. It had worked older versions of Tiled because visibility toggle was implemented as a checkbox and Space toggles checkboxes by default. Since 359dcb9 (Tiled 1.3.0) there is a global shortcut for toggling visibility of the selected layer(s), which is Ctrl+H, so the Space (and Ctrl+Space) shortcuts could probably just be removed.

Of course, the problem will remain for any text inputs, but they are much more rare to be focused (most common might be the Console text input).

bjorn added a commit to bjorn/tiled-dev that referenced this issue Apr 24, 2023
This reverts commit 0de0f20.

This shortcut was only provided for backwards compatibility, but it
often conflicts with using Space for panning the map view and since
359dcb9 there are global shortcuts
available for toggling layer visility and locked status, making this
shortcut no longer necessary.

See issue mapeditor#3672.
@ankisme
Copy link
Author

ankisme commented Apr 24, 2023

There still a little inconvient of [Space], because toggle visible by [Space] should be triggered only when [Space] be pressed up, and now it will be triggerred when [Space] pressed down.

And if it's triggered when [Space] be pressed up, perhaps [Space] will not conflict with [Space + Left Click].

@bjorn
Copy link
Member

bjorn commented Apr 24, 2023

There still a little inconvient of [Space], because toggle visible by [Space] should be triggered only when [Space] be pressed up, and now it will be triggerred when [Space] pressed down.

Why do you think it's preferable to toggle visibility on release rather than press? Usually shortcuts work on press. Although, in this particular case, the checkbox didn't actually toggle until space had been released.

And if it's triggered when [Space] be pressed up, perhaps [Space] will not conflict with [Space + Left Click].

If the space press is not handled, then the press will trigger the panning mode, and then the release is expected to end the panning mode, rather than (also) toggling layer visibility, I think.

In any case, I've suggested the removal of this shortcut entirely in PR #3673.

@ankisme
Copy link
Author

ankisme commented Apr 24, 2023

You are right, many key and shortcut key of OS is triggered on press, not release, such as [Win + R] [Alt + Tab] in windows, I forget it.

bjorn added a commit to bjorn/tiled-dev that referenced this issue Apr 25, 2023
This reverts commit 0de0f20.

This shortcut was only provided for backwards compatibility, but it
often conflicts with using Space for panning the map view and since
359dcb9 there are global shortcuts
available for toggling layer visility and locked status, making this
shortcut no longer necessary.

See issue mapeditor#3672.
bjorn added a commit that referenced this issue Apr 25, 2023
This reverts commit 0de0f20.

This shortcut was only provided for backwards compatibility, but it
often conflicts with using Space for panning the map view and since
359dcb9 there are global shortcuts
available for toggling layer visility and locked status, making this
shortcut no longer necessary.

See issue #3672.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

No branches or pull requests

2 participants