Make sure we release the keydown handle
This commit is contained in:
parent
c96b16cf56
commit
d1056ceccc
1 changed files with 10 additions and 4 deletions
|
|
@ -773,11 +773,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
parent = parent.Parent;
|
||||
}
|
||||
UnHookWidgetThatHasKeyDownHooked();
|
||||
parent.KeyDown += Parent_KeyDown;
|
||||
widgetThatHasKeyDownHooked = parent;
|
||||
}
|
||||
}
|
||||
|
||||
void UnHookWidgetThatHasKeyDownHooked()
|
||||
{
|
||||
if (widgetThatHasKeyDownHooked != null)
|
||||
{
|
||||
widgetThatHasKeyDownHooked.KeyDown -= Parent_KeyDown;
|
||||
}
|
||||
}
|
||||
|
||||
void Parent_KeyDown(object sender, KeyEventArgs keyEvent)
|
||||
{
|
||||
if (keyEvent.KeyCode == Keys.Up)
|
||||
|
|
@ -982,10 +991,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
if (widgetThatHasKeyDownHooked != null)
|
||||
{
|
||||
widgetThatHasKeyDownHooked.KeyDown -= Parent_KeyDown;
|
||||
}
|
||||
UnHookWidgetThatHasKeyDownHooked();
|
||||
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue