Fix renaming selected actor in scene tree after creation and use editor shortcut
This commit is contained in:
@@ -293,21 +293,6 @@ namespace FlaxEditor.SceneGraph.GUI
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnKeyDown(KeyboardKeys key)
|
||||
{
|
||||
if (IsFocused)
|
||||
{
|
||||
if (key == KeyboardKeys.F2)
|
||||
{
|
||||
StartRenaming();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnKeyDown(key);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override DragDropEffect OnDragEnterHeader(DragData data)
|
||||
{
|
||||
|
||||
@@ -163,7 +163,13 @@ namespace FlaxEditor.Windows.Assets
|
||||
|
||||
private void Rename()
|
||||
{
|
||||
((ActorNode)Selection[0]).TreeNode.StartRenaming();
|
||||
var selection = Selection;
|
||||
if (selection.Count != 0 && selection[0] is ActorNode actor)
|
||||
{
|
||||
if (selection.Count != 0)
|
||||
Select(actor);
|
||||
actor.TreeNode.StartRenaming();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -184,6 +184,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
InputActions.Add(options => options.Paste, Paste);
|
||||
InputActions.Add(options => options.Duplicate, Duplicate);
|
||||
InputActions.Add(options => options.Delete, Delete);
|
||||
InputActions.Add(options => options.Rename, Rename);
|
||||
InputActions.Add(options => options.FocusSelection, _viewport.FocusSelection);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace FlaxEditor.Windows
|
||||
InputActions.Add(options => options.RotateMode, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate);
|
||||
InputActions.Add(options => options.ScaleMode, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale);
|
||||
InputActions.Add(options => options.FocusSelection, () => Editor.Windows.EditWin.Viewport.FocusSelection());
|
||||
InputActions.Add(options => options.Rename, Rename);
|
||||
}
|
||||
|
||||
private void OnSearchBoxTextChanged()
|
||||
@@ -91,7 +92,13 @@ namespace FlaxEditor.Windows
|
||||
|
||||
private void Rename()
|
||||
{
|
||||
(Editor.SceneEditing.Selection[0] as ActorNode).TreeNode.StartRenaming();
|
||||
var selection = Editor.SceneEditing.Selection;
|
||||
if (selection.Count != 0 && selection[0] is ActorNode actor)
|
||||
{
|
||||
if (selection.Count != 0)
|
||||
Editor.SceneEditing.Select(actor);
|
||||
actor.TreeNode.StartRenaming();
|
||||
}
|
||||
}
|
||||
|
||||
private void Spawn(Type type)
|
||||
|
||||
Reference in New Issue
Block a user