Skip to content

Commit

Permalink
feat: Change background when Key is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanMagnet committed Aug 28, 2024
1 parent 94b1419 commit ccb264a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/UnoKeyboard/Controls/KeyControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,27 @@ public KeyControl(KeyboardControl keyboard)
Mode = BindingMode.OneWay,
});

// Change key background when the key is pressed
this.PointerPressed += (s, e) =>
{
//ControlBorder.Background = new SolidColorBrush(Colors.DimGray);
if (ControlBorder.Background is SolidColorBrush originalBrush)
{
// Obtener el color original
var originalColor = originalBrush.Color;

// Modificar el canal alfa, por ejemplo, al 50%
var newColor = Windows.UI.Color.FromArgb(50, originalColor.R, originalColor.G, originalColor.B);

// Aplicar el nuevo color al fondo
ControlBorder.Background = new SolidColorBrush(newColor);
}
};

this.PointerReleased += (s, e) =>
{
ControlBorder.Background = Keyboard.KeyBackground;

e.Handled = true;

KeyPressed?.Invoke(this, new KeyEventArgs(Key, IsShiftActive));
Expand Down

0 comments on commit ccb264a

Please sign in to comment.