rfaile313 / cavatars-game

A Multiplayer web-browser game based on the "codenames" board game built using NodeJS, Socket.io, and Phaser3
https://rudyfaile.com
8 stars 0 forks source link

[Bug] Can't put spaces into any of the input boxes (name, chat, etc.) #3

Closed rfaile313 closed 3 years ago

rfaile313 commented 3 years ago

These two boxes, for example:

Screenshot_4

I don't really mind that player names don't have spaces, but would like folks to be able to make spaces in chat.

Abdelilah-Majid commented 3 years ago

can you explain more what is the problem exactly

Abdelilah-Majid commented 3 years ago

i will try to fix that

Abdelilah-Majid commented 3 years ago

oh! sorry i forgot i have some work to do sorry i wanted to work on your game but i have somethings to do

rfaile313 commented 3 years ago

If you build the program and run it you'll see that you can't put spaces in any of the text input boxes, that is the bug.

rfaile313 commented 3 years ago

This is fixed. I found out you can't access these properties directly and need to use the built in functions from phaser due to getters/setters and actually removing/adding event listeners.

Specifically, calling disableGlobalCapture() and enableGlobalCapture()

Solution:

  const chatBox = document.getElementById("chat");
  chatBox.addEventListener("focus", () => {this.input.keyboard.disableGlobalCapture()});
  chatBox.addEventListener("blur", () =>  {this.input.keyboard.enableGlobalCapture()});

See: https://photonstorm.github.io/phaser3-docs/Phaser.Input.Keyboard.KeyboardPlugin.html