Closed Danii0206 closed 1 year ago
it also duplicates chat messages (including whispering)
I don't know in which file and where to put that. Can you help?
I've spoken with @cswendrowski about a possible change to core that could solve this for everyone, provided we all follow up by altering our own code to leverage that change.
You can view the issue I created here: https://gitlab.com/foundrynet/foundryvtt/-/issues/5300
If this gets implemented, I'll fix autocomplete whisper so that it's not breaking any other modules competing for this same keybind... Chat-Commands-Lib and DSA5 need to do their part as well.
Running into similar issues with my own system.
This does not require a namespace (or other adjustments) to fix. The "recommended" way (in quotation marks because StackOverflow is not a universal truth) is to bind your event handler as the first one and then use regular event propagation.
Example code:
function onFirst(element, eventName, selector, eventHandler) {
element.on(eventName, selector, eventHandler);
let handlers = jQuery._data(element[0]).events[eventName.split('.')[0]];
handlers.unshift(handlers.pop());
return element;
}
// Instead of unbinding the original handler...
// $("#chat-message").off("keydown");
// $("#chat-message").on("keydown.menufocus", jumpToMenuHandler);
// ...make sure that the new one runs first:
onFirst($("#chat-message"), "keydown.menufocus", jumpToMenuHandler);
You can then use return false
in your handler to prevent propagation and return true
/return
to propagate normally.
THIS is the solution. Right here. CC: @cswendrowski
This is precisely how I wanted it to function when I first developed this module, but couldn't figure out how. I have now tested this solution with my module in DSA (and D&D5e) and while running Library: Chat Commands, and it appears to work in all scenarios. Can't thank you enough for finding this perfect solution.
Side note, I know this ain't exactly a timely response here. My apologies. I've been very busy but I don't know how I missed this comment for nearly a year.
Thanks again. Awesome solution @DJ4ddi.
Hello,
this module makes all rolls from the chat roll 2 times when the system "Das Schwarze Auge/The Dark Eye (5th Edition)" is used. Can you please have a look?
Kind regards Danii