Skip to content

Commit

Permalink
Fix clicks on pieces on hand registering as board clicks
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
TollyH committed Mar 25, 2023
1 parent 78d4ac4 commit bc0bd79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,8 @@ private async void Window_MouseDown(object sender, MouseButtonEventArgs e)
return;
}

if (selectedDropType is not null)
if (selectedDropType is not null && mousePos.X >= 0 && mousePos.Y >= 0 && mousePos.X <= shogiGameCanvas.ActualWidth
&& mousePos.Y <= shogiGameCanvas.ActualHeight)
{
System.Drawing.Point destination = GetCoordFromCanvasPoint(mousePos);
bool success = game.MovePiece(ShogiGame.PieceDropSources[selectedDropType], destination, doPromotion: null);
Expand Down

0 comments on commit bc0bd79

Please sign in to comment.