GithubHelp home page GithubHelp logo

relick / foundryvtt-right-click-enabler Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 16 KB

Allows you to use the standard context menu in places where Foundry does not use right-click.

Home Page: https://raw.githubusercontent.com/relick/FoundryVTT-Right-Click-Enabler/master/module.json

License: GNU General Public License v3.0

JavaScript 100.00%

foundryvtt-right-click-enabler's Introduction

πŸŽ€ Hello! I'm a game developer with interests in Dungeons & Dragons, Touhou Project, C++, and music for the Mega Drive.

πŸŽ€ Check my website at kasha.dev

foundryvtt-right-click-enabler's People

Contributors

relick avatar

Stargazers

 avatar

Watchers

 avatar  avatar

foundryvtt-right-click-enabler's Issues

[Compatibility Issue] Replacing 'Game' is not a good idea.

Hello,

It has come to my attention that since 0.8.9 this module breaks libWrapper, as well as some modules that hook a function in Game. A quick investigation shows that this is caused by the fact that you replace the entirety of the Game class with a patched toString() version.

The problem here is that the toString() version of a method/class is not guaranteed to correspond to the actual code, especially if any method has been patched by another module. For example, variables that are from scopes outside the class (e.g. specific to a given method) will not be accessible. Methods might rely on native code and thus contain [native] blocks, etc. Using it for a single method is already an issue sometimes, but using it for an entire class - especially one modified by many modules - is a really bad idea if you want to have good compatibility with other modules.

In this case, libWrapper will patch Game.prototype.initialize to complete its initialisation, but this patch is thrown out when you replace the Game class, causing libWrapper to never fully initialise. This used to work before 0.8.9 as libWrapper would load after your module, but in 0.8.9 the module loading order changed, and now your module loads after.

Some other modules that patch Game also lose their patches and stop working correctly, but neither fails as obviously as libWrapper.

Given you want to remove the line document.addEventListener("contextmenu", ev => ev.preventDefault()); in method Game.prototype.activateListeners, you could achieve the exact same result without being a nightmare for module compatibility, by restricting your patch to the activateListeners method itself, e.g.:

const fnStr = Game.prototype.activateListeners.toString();
const patchedFnStr = fnStr .replace(`document.addEventListener("contextmenu", ev => ev.preventDefault());`, ``);
Game.prototype.activateListeners = Function('"use strict"; return (function ' + patchedFnStr + ')')();

Seems to break FXMaster.

With this module enabled, the menu for FXMaster doesn't render; I only get the first 3 options (nothing after Snow).

Seems odd, but disabling the module gives me back the whole menu.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.