feat: reordering
This commit is contained in:
@@ -38,12 +38,14 @@ namespace CarManagerV3
|
||||
|
||||
foreach (Control ctrl in this.Controls)
|
||||
{
|
||||
ctrl.Click += ForwardClick;
|
||||
foreach (Control inner in ctrl.Controls) // In case you have nested controls
|
||||
inner.Click += ForwardClick;
|
||||
ctrl.MouseClick += ForwardClick;
|
||||
foreach (Control inner in ctrl.Controls)
|
||||
{
|
||||
inner.MouseClick += ForwardClick;
|
||||
}
|
||||
}
|
||||
|
||||
this.Click += (s, e) => this.OnCardClicked();
|
||||
this.MouseClick += (s, e) => this.OnCardClicked(s, e);
|
||||
}
|
||||
|
||||
public async void LoadImage()
|
||||
@@ -59,15 +61,22 @@ namespace CarManagerV3
|
||||
});
|
||||
}
|
||||
|
||||
private void ForwardClick(object sender, EventArgs e)
|
||||
private void ForwardClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Raise your CardClicked event no matter what got clicked
|
||||
if (e.Button == MouseButtons.Right) return;
|
||||
|
||||
Console.WriteLine($"Forwarding click from {sender.GetType().Name}");
|
||||
CardClicked?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler CardClicked;
|
||||
private void OnCardClicked()
|
||||
private void OnCardClicked(object sender, MouseEventArgs e)
|
||||
{
|
||||
Console.WriteLine($"Card clicked at {e.Location} with button {e.Button}");
|
||||
if (e.Button == MouseButtons.Right) return;
|
||||
Console.WriteLine($"Card clicked: {this.CarName}");
|
||||
|
||||
if (this.CardClicked != null)
|
||||
{
|
||||
this.CardClicked(this, EventArgs.Empty);
|
||||
|
||||
Reference in New Issue
Block a user