getting right click working in library view rows
issue: MatterHackers/MCCentral#4418 Set selectable false for Icon view rows to fix right click
This commit is contained in:
parent
c57a297ccf
commit
5abe0d4b13
2 changed files with 37 additions and 2 deletions
|
|
@ -76,6 +76,17 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
base.OnBoundsChanged(e);
|
||||
}
|
||||
|
||||
private void Row_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is GuiWidget guiWidget)
|
||||
{
|
||||
var screenPosition = guiWidget.TransformToScreenSpace(e.Position);
|
||||
var thisPosition = this.TransformFromScreenSpace(screenPosition);
|
||||
var thisMouseClick = new MouseEventArgs(e, thisPosition.X, thisPosition.Y);
|
||||
OnClick(thisMouseClick);
|
||||
}
|
||||
}
|
||||
|
||||
private void LayoutIcons()
|
||||
{
|
||||
int currentWidth = (int)this.Size.X;
|
||||
|
|
@ -95,6 +106,11 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
iconView.Margin = new BorderDouble(leftRightMargin, 0);
|
||||
}
|
||||
|
||||
foreach(var child in Children)
|
||||
{
|
||||
child.Click -= Row_Click;
|
||||
}
|
||||
|
||||
this.CloseAllChildren();
|
||||
|
||||
foreach (var iconView in allIconViews)
|
||||
|
|
@ -173,6 +189,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
Margin = new BorderDouble(bottom: 6)
|
||||
};
|
||||
this.AddChild(rowButtonContainer);
|
||||
rowButtonContainer.Click += Row_Click;
|
||||
}
|
||||
|
||||
rowButtonContainer?.AddChild(iconView);
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
contentView = new IconListView(theme);
|
||||
|
||||
libraryView.Click += ContentView_Click;
|
||||
|
||||
loadingBackgroundColor = new Color(theme.PrimaryAccentColor, 10);
|
||||
|
||||
this.theme = theme;
|
||||
|
|
@ -89,6 +91,17 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
context.ContentChanged += ActiveContainer_ContentChanged;
|
||||
}
|
||||
|
||||
private void ContentView_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is GuiWidget guiWidget)
|
||||
{
|
||||
var screenPosition = guiWidget.TransformToScreenSpace(e.Position);
|
||||
var thisPosition = this.TransformFromScreenSpace(screenPosition);
|
||||
var thisMouseClick = new MouseEventArgs(e, thisPosition.X, thisPosition.Y);
|
||||
ShowRightClickMenu(thisMouseClick);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowItems { get; set; } = true;
|
||||
|
||||
public bool AllowContextMenu { get; set; } = true;
|
||||
|
|
@ -451,6 +464,13 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
public bool HasMenu { get; set; } = true;
|
||||
|
||||
public override void OnClick(MouseEventArgs mouseEvent)
|
||||
{
|
||||
ShowRightClickMenu(mouseEvent);
|
||||
|
||||
base.OnClick(mouseEvent);
|
||||
}
|
||||
|
||||
private void ShowRightClickMenu(MouseEventArgs mouseEvent)
|
||||
{
|
||||
var bounds = this.LocalBounds;
|
||||
var hitRegion = new RectangleDouble(
|
||||
|
|
@ -509,8 +529,6 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
},
|
||||
altBounds: popupBounds);
|
||||
}
|
||||
|
||||
base.OnClick(mouseEvent);
|
||||
}
|
||||
|
||||
public override void OnMouseWheel(MouseEventArgs mouseEvent)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue