Skip to content

Edit node name (if any) when F2 is pressed #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ReClass.NET/Forms/MainForm.Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,17 @@ private void PasteNodeFromClipboardToSelection()
}
}

private void EditSelectedNodeName()
{
var selected = memoryViewControl.GetSelectedNodes();
var selectedNode = selected.FirstOrDefault();

if (selected.Count == 1)
{
memoryViewControl.ShowEditBoxForName(selectedNode);
}
}

private void RemoveSelectedNodes()
{
memoryViewControl.GetSelectedNodes()
Expand Down
26 changes: 14 additions & 12 deletions ReClass.NET/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -766,22 +766,24 @@ private void classesView_ClassSelected(object sender, ClassNode node)
CurrentClassNode = node;
}

private void memoryViewControl_KeyDown(object sender, KeyEventArgs e)
private void memoryViewControl_KeyDown(object sender, KeyEventArgs args)
{
if (e.Control)
switch (args.KeyCode)
{
if (e.KeyCode == Keys.C)
{
case Keys.C when args.Control:
CopySelectedNodesToClipboard();
}
else if (e.KeyCode == Keys.V)
{
break;
case Keys.V when args.Control:
PasteNodeFromClipboardToSelection();
}
}
else if (e.KeyCode == Keys.Delete)
{
RemoveSelectedNodes();
break;

case Keys.Delete:
RemoveSelectedNodes();
break;

case Keys.F2:
EditSelectedNodeName();
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion ReClass.NET/UI/HotSpotTextBox.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel;
using System.Windows.Forms;

Expand Down
2 changes: 1 addition & 1 deletion ReClass.NET/UI/MemoryViewControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions ReClass.NET/UI/MemoryViewControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,20 @@ protected override void OnMouseDoubleClick(MouseEventArgs e)
base.OnMouseDoubleClick(e);
}

public void ShowEditBoxForName(SelectedNodeInfo selection)
{
var hotSpot = hotSpots.FirstOrDefault(spot => spot.Address == selection.Address &&
spot.Type == HotSpotType.Edit &&
spot.Text == selection.Node.Name);
if (hotSpot != null)
{
editBox.BackColor = Program.Settings.SelectedColor;
editBox.HotSpot = hotSpot;
editBox.Visible = true;
editBox.ReadOnly = false;
}
}

private Point toolTipPosition;
protected override void OnMouseHover(EventArgs e)
{
Expand Down Expand Up @@ -631,6 +645,8 @@ private void editBox_Committed(object sender, EventArgs e)

Invalidate();
}

Focus();
}

#endregion
Expand Down