lichess-org / chessground

Mobile/Web chess UI for lichess.org
https://lichess.org
GNU General Public License v3.0
1.01k stars 260 forks source link

Click #293

Closed rdeyo1129 closed 8 months ago

rdeyo1129 commented 8 months ago

Hello, I'm trying to implement a drop piece feature that doesn't use drag and drop but just click piece and then have the 'droppable' (or clickable in this case) dests to highlight the same way it works for regular moves. Here's some of the code that I'm trying and working with. I noticed the selected.enabled comment seems to be hinting at a click click feature if set to true, but it's not working. I also saw a working example of this in the pychess 'placement' variant. Any help or pointers is very appreciated, thank you.

value passed into dests prop

0
: 
{"Q@" => Array(24)}
key
: 
"Q@"
value
: 
(24) ['a3', 'b3', 'c3', 'd3', 'e3', 'f3', 'g3', 'h3', 'a4', 'b4', 'c4', 'd4', 'e4', 'f4', 'g4', 'h4', 'a5', 'b5', 'c5', 'd5', 'e5', 'f5', 'g5', 'h5']
size
: 
1

config.ts:

  selectable?: {
    enabled?: boolean; // disable to enforce dragging over click-click move
    selected?: cg.Selectable; // square or piece currently selected "a1"
    fromPocket?: boolean; // whether the selected piece is from the pocket
  };

property used in the client via :

selectable={{
              enabled: true, // disable to enforce dragging over click-click move
              selected: {
                role: 'r-piece', // class name of chess piece
                color: 'white', // color of chess piece
              }, // square or piece currently selected "a1"
              fromPocket: true, // whether the selected piece is from the pocket
            }}
gbtami commented 8 months ago

You may try to use our chessground fork https://github.com/gbtami/chessgroundx It has built in pocket handling for drop variants.

rdeyo1129 commented 8 months ago

@gbtami thanks for the response, yeah my repo is a fork of chessgroundx.. Sorry, wrong repo.

rdeyo1129 commented 8 months ago

@gbtami I solved the issue, was looking for selectPocket in the api. Thanks again.