Skip to content

Commit

Permalink
rename by hotkey (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Artauthr authored Nov 21, 2024
1 parent cedec28 commit 1d283df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,20 @@ public void deleteSelected () {
}
}

public void renameSelected () {
if (tree.getSelection().size() == 1) {
FilteredTree.Node<GameObject> node = tree.findNode(tree.getSelection().first().getObject());
if (node != null) {
if (node.getActor() instanceof HierarchyWrapper) {
HierarchyWrapper wrapper = (HierarchyWrapper)node.getActor();
if (wrapper.label instanceof EditableLabel) {
((EditableLabel)wrapper.label).setEditMode();
}
}
}
}
}

public void pasteFromClipboard () {
SceneUtils.paste(gameAsset);
}
Expand Down Expand Up @@ -467,17 +481,7 @@ public void clicked (InputEvent event, float x, float y) {
MenuItem rename = contextualMenu.addItem("Rename", new ClickListener() {
@Override
public void clicked (InputEvent event, float x, float y) {
if (tree.getSelection().size() == 1) {
FilteredTree.Node<GameObject> node = tree.findNode(tree.getSelection().first().getObject());
if (node != null) {
if (node.getActor() instanceof HierarchyWrapper) {
HierarchyWrapper wrapper = (HierarchyWrapper)node.getActor();
if (wrapper.label instanceof EditableLabel) {
((EditableLabel)wrapper.label).setEditMode();
}
}
}
}
renameSelected();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,8 @@ public void onCutCommand (CommandContextEvent event) {
public void onPasteCommand (CommandContextEvent commandContextEvent) {
hierarchyWidget.pasteFromClipboard();
}

@CommandEventHandler(commandType = Commands.CommandType.RENAME)
public void onRenameCommand (CommandContextEvent commandContextEvent) { hierarchyWidget.renameSelected(); }
}

0 comments on commit 1d283df

Please sign in to comment.