Cache context menu and add check to prevent accidental duplication.
This commit is contained in:
@@ -75,6 +75,7 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
private bool _isRegisteredForScriptsReload;
|
private bool _isRegisteredForScriptsReload;
|
||||||
private Label _typeText;
|
private Label _typeText;
|
||||||
private ToolStripButton _optionsButton;
|
private ToolStripButton _optionsButton;
|
||||||
|
private ContextMenu _optionsCM;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the instance of the Json asset object that is being edited.
|
/// Gets the instance of the Json asset object that is being edited.
|
||||||
@@ -240,10 +241,13 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
|
|
||||||
private void OpenOptionsContextMenu()
|
private void OpenOptionsContextMenu()
|
||||||
{
|
{
|
||||||
var cm = new ContextMenu();
|
if (_optionsCM != null && _optionsCM.ContainsFocus)
|
||||||
cm.AddButton("Copy type name", () => Clipboard.Text = Asset.DataTypeName);
|
return;
|
||||||
cm.AddButton("Copy Asset data", () => Clipboard.Text = Asset.Data);
|
|
||||||
cm.AddButton("Paste Asset data", () =>
|
_optionsCM = new ContextMenu();
|
||||||
|
_optionsCM.AddButton("Copy type name", () => Clipboard.Text = Asset.DataTypeName);
|
||||||
|
_optionsCM.AddButton("Copy Asset data", () => Clipboard.Text = Asset.Data);
|
||||||
|
_optionsCM.AddButton("Paste Asset data", () =>
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Clipboard.Text))
|
if (!string.IsNullOrEmpty(Clipboard.Text))
|
||||||
{
|
{
|
||||||
@@ -274,21 +278,21 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cm.Enabled = !string.IsNullOrEmpty(Clipboard.Text);
|
_optionsCM.Enabled = !string.IsNullOrEmpty(Clipboard.Text);
|
||||||
cm.AddSeparator();
|
_optionsCM.AddSeparator();
|
||||||
if (_optionsButton.Tag is ContentItem item)
|
if (_optionsButton.Tag is ContentItem item)
|
||||||
{
|
{
|
||||||
cm.AddButton("Edit Asset code", () =>
|
_optionsCM.AddButton("Edit Asset code", () =>
|
||||||
{
|
{
|
||||||
Editor.Instance.ContentEditing.Open(item);
|
Editor.Instance.ContentEditing.Open(item);
|
||||||
});
|
});
|
||||||
cm.AddButton("Show Asset code item in content window", () =>
|
_optionsCM.AddButton("Show Asset code item in content window", () =>
|
||||||
{
|
{
|
||||||
Editor.Instance.Windows.ContentWin.Select(item);
|
Editor.Instance.Windows.ContentWin.Select(item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cm.Show(_optionsButton, _optionsButton.PointFromScreen(Input.MouseScreenPosition));
|
_optionsCM.Show(_optionsButton, _optionsButton.PointFromScreen(Input.MouseScreenPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user