Skip to content

Commit

Permalink
Editor: allow drag and drop to WatchPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Nov 13, 2024
1 parent d719aff commit 677a156
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Editor/AGS.Editor/GUI/WatchVariablesPanel.Designer.cs

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

47 changes: 47 additions & 0 deletions Editor/AGS.Editor/GUI/WatchVariablesPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,5 +522,52 @@ private void WatchVariablesPanel_Load(object sender, EventArgs e)
Factory.GUIController.ColorThemes.Apply(LoadColorTheme);
}
}

private static string GetDraggedVar(DragEventArgs e)
{
string droppedWord = string.Empty;

try
{
// must be a text we got from somewhere, probably script editor
if (e.Data.GetDataPresent(DataFormats.Text))
{
// Retrieve the text from the drag-and-drop data
string droppedText = (string)e.Data.GetData(DataFormats.Text);

if (!string.IsNullOrWhiteSpace(droppedText) && droppedText.IndexOfAny(new[] { ' ', '\n' }) == -1)
{
droppedWord = droppedText;
}
}
}
catch (Exception ex)
{
// do nothing
}

// TO-DO: make it actually select a valid variable somehow
return droppedWord;
}

private void listView1_DragDrop(object sender, DragEventArgs e)
{
string droppedVar = GetDraggedVar(e);
if (String.IsNullOrEmpty(droppedVar))
return;
AddVariableToWatchList(droppedVar);
}

private void listView1_DragEnter(object sender, DragEventArgs e)
{
string droppedVar = GetDraggedVar(e);
if (String.IsNullOrEmpty(droppedVar))
{
e.Effect = DragDropEffects.None;
return;
}

e.Effect = DragDropEffects.Copy; // Allow copy operation
}
}
}

0 comments on commit 677a156

Please # to comment.