react-chessboard icon indicating copy to clipboard operation
react-chessboard copied to clipboard

Is it possible to create arrows of different colors with different cmouse and keyboard keys events?

Open maooricio opened this issue 1 year ago • 5 comments

https://github.com/user-attachments/assets/9670d40f-9269-403e-ac89-32c1667ddd02

Is it possible to create arrows with different colors taking into account the click on the mouse key and some keys in the keyboard like Shift and Alt? This is in order to replicate this behaviour that you see at the video that was taken from lichess. In advance thanks

maooricio avatar Aug 05 '24 08:08 maooricio

Shift + Left click = Green arrow Shift + Right click = Red arrow Shift + Alt + Left click = Blue arrow Shift + Alt + Right click = Yellow arrow

maooricio avatar Aug 05 '24 08:08 maooricio

Hmm wouldn't just having a listener to set the color of the customArrowColor prop based on the key presses work?

DevArches avatar Aug 05 '24 12:08 DevArches

But how can I keep the different arrow colors, because I can set there only one color, so if I change that variable, all the arrows are going to change their color, not in an individual way

maooricio avatar Aug 07 '24 06:08 maooricio

Hmm good point. I'm only brainstorming but couldn't you then set the customArrows prop to do that then? A listener to set the color based on keys pressed. From is just set onSquareRightClick and to set onMouseOverSquare with a possible cleanup onMouseOutSquare. Again, just brainstorming and I haven't tested it. But seems feasible. If that doesn't work then it's probably a good feature requst as I can see people using that :)

DevArches avatar Aug 07 '24 06:08 DevArches

I am not sure about the shortcuts etc, but it's possible. We use colours at the bottom of the board image

We are also providing the property customArrows for that use case.

ahofmeister avatar Sep 18 '24 11:09 ahofmeister

closing due to no activity

Clariity avatar Nov 04 '24 15:11 Clariity