shemetz / ZoomPanOptions

FoundryVTT module for zooming and panning better
MIT License
7 stars 8 forks source link

[request] disable CTRL click = Right click on Mac #63

Closed dodds-steven closed 2 months ago

dodds-steven commented 2 months ago

LOVE this mod so much! I'm track pad user on Mac and have been since they became an option on desktop. this is a life saver mod!

I don't know if this may be possible, but if we could disable the Mac's CTRL-Click = Right click functionality as well, that would be awesome. Foundry doesn't seem to let me change this in configure controls.... :(. it gets in the way of mods assuming windows CTRL click to select multiple....

I'm open to other options if anyone has suggestions.

shemetz commented 2 months ago

Can you explain exactly in what situations the Ctrl click bothers you on Mac?

Panning? Zooming? Opening menus? etc.

dodds-steven commented 2 months ago

Many systems and mods use CTRL to select many things. This is not possible to do using a Mac because CTRl click gives us the same as right click. Apple in their grand wisdom hasn’t given us a means to disable this legacy function from single button mice days…. In some cases Foundry maps the Mac Command key to what would be a windows hot key. Example. Command-c is Copy on a Mac.

So I guess to answer your question more directly... only people with a bad habit after using single button mice need the Mac to emulate mouse button 2 (contextual menu usually) and in the context of foundry I can’t see anyone needing ctrl-click to equal right click. 99.9% of modern Mac’s being used should have that legacy function disabled. ( Unless they actually want to use a 1 button mouse! I use trackpads on laptops and desktop. The game system I’m working with (ARS) has used CTRL click to multi select inventory items. Mac used can’t do it because it doesn’t work. We get the context menu… There are other mods that I know what to let you multi select using the CTRL key and those are also busted. At least the ones I tested, because if the same thing. so if your fantastic mod could disable Mac CTRL-Click equals right click, it could likely fix everything

shemetz commented 2 months ago

Sorry, there's no way to unmap the Ctrl+Click context menu action in Mac, at least not in the browser with javascript.

However, what most codebases are doing is to treat Cmd and Ctrl as the same button. This means always checking using game.keyboard.isModifierActive(KeyboardManager.MODIFIER_KEYS.CONTROL) or event.ctrlKey || event.metaKey, depending on context.

For example, in ZoomPanOptions I currently have this line of code in the mouse wheel listener:

  const ctrlOrMeta = event.ctrlKey || event.metaKey  // meta key (cmd on mac, winkey in windows) will behave like ctrl

Which should make scrolling work fine using the Meta key, with the same experience as a Windows user using Ctrl key.

I think your problem is this part

The game system I’m working with (ARS) has used CTRL click to multi select inventory items. Mac used can’t do it because it doesn’t work. We get the context menu… There are other mods that I know what to let you multi select using the CTRL key and those are also busted.

You should create bug reports for those systems and ask that they change the selection code to be Mac-compatible and allow the Cmd (meta) key to function as an alternative to Ctrl.

For example, I see that the ARS system code has lots of cases (like here) where they only check event.ctrlKey, and should instead be checking one of the following:

  1. event.ctrlKey || event.metaKey
  2. game.keyboard.isModifierActive(KeyboardManager.MODIFIER_KEYS.CONTROL)

I hope this explanation helps -- feel free to link it or send bits of it to the other developers. I'll close the ticket now (since it isn't related to this specific module).