mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 08:55:38 +02:00
CR feedback
This commit is contained in:
parent
e5ef589a3c
commit
4069ca2e0c
2 changed files with 19 additions and 19 deletions
scripts/system/html/js
|
@ -231,8 +231,11 @@ function loaded() {
|
|||
elRenameInput.select();
|
||||
}
|
||||
|
||||
entityListContextMenu.setCallback(function(optionName, selectedEntityID) {
|
||||
entityListContextMenu.setOnSelectedCallback(function(optionName, selectedEntityID) {
|
||||
switch (optionName) {
|
||||
case "Cut":
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'cut' }));
|
||||
break;
|
||||
case "Copy":
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'copy' }));
|
||||
break;
|
||||
|
@ -263,8 +266,6 @@ function loaded() {
|
|||
focus: false,
|
||||
entityIds: selection,
|
||||
}));
|
||||
|
||||
refreshFooter();
|
||||
}
|
||||
|
||||
let enabledContextMenuItems = [];
|
||||
|
@ -765,7 +766,7 @@ function loaded() {
|
|||
augmentSpinButtons();
|
||||
|
||||
document.addEventListener("contextmenu", function (event) {
|
||||
entityListContextMenu.close.call(entityListContextMenu);
|
||||
entityListContextMenu.close();
|
||||
|
||||
// Disable default right-click context menu which is not visible in the HMD and makes it seem like the app has locked
|
||||
event.preventDefault();
|
||||
|
@ -773,6 +774,6 @@ function loaded() {
|
|||
|
||||
// close context menu when switching focus to another window
|
||||
$(window).blur(function() {
|
||||
entityListContextMenu.close.call(entityListContextMenu);
|
||||
entityListContextMenu.close();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ const CONTEXT_MENU_CLASS = "context-menu";
|
|||
*/
|
||||
function EntityListContextMenu() {
|
||||
this._elContextMenu = null;
|
||||
this._callback = null;
|
||||
this._onSelectedCallback = null;
|
||||
this._listItems = [];
|
||||
this._initialize();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ EntityListContextMenu.prototype = {
|
|||
/**
|
||||
* @private
|
||||
*/
|
||||
_callback: null,
|
||||
_onSelectedCallback: null,
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
@ -82,20 +82,19 @@ EntityListContextMenu.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Set the event callback
|
||||
* @param callback
|
||||
* Set the callback for when a menu item is selected
|
||||
* @param onSelectedCallback
|
||||
*/
|
||||
setCallback: function(callback) {
|
||||
this._callback = callback;
|
||||
setOnSelectedCallback: function(onSelectedCallback) {
|
||||
this._onSelectedCallback = onSelectedCallback;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a labeled item to the context menu
|
||||
* @param itemLabel
|
||||
* @param isEnabled
|
||||
* @private
|
||||
*/
|
||||
_addListItem: function(itemLabel, isEnabled) {
|
||||
_addListItem: function(itemLabel) {
|
||||
let elListItem = document.createElement("li");
|
||||
elListItem.innerText = itemLabel;
|
||||
|
||||
|
@ -106,8 +105,8 @@ EntityListContextMenu.prototype = {
|
|||
};
|
||||
|
||||
elListItem.addEventListener("click", function () {
|
||||
if (listItem.enabled && this._callback) {
|
||||
this._callback.call(this, itemLabel, this._selectedEntityID);
|
||||
if (listItem.enabled && this._onSelectedCallback) {
|
||||
this._onSelectedCallback.call(this, itemLabel, this._selectedEntityID);
|
||||
}
|
||||
}.bind(this), false);
|
||||
|
||||
|
@ -136,12 +135,12 @@ EntityListContextMenu.prototype = {
|
|||
this._elContextMenu.setAttribute("class", CONTEXT_MENU_CLASS);
|
||||
document.body.appendChild(this._elContextMenu);
|
||||
|
||||
// TODO: enable Copy, Paste and Duplicate items once implemented
|
||||
this._addListItem("Copy", false);
|
||||
this._addListItem("Paste", false);
|
||||
this._addListItem("Cut");
|
||||
this._addListItem("Copy");
|
||||
this._addListItem("Paste");
|
||||
this._addListSeparator();
|
||||
this._addListItem("Rename");
|
||||
this._addListItem("Duplicate", false);
|
||||
this._addListItem("Duplicate");
|
||||
this._addListItem("Delete");
|
||||
|
||||
// Ignore clicks on context menu background or separator.
|
||||
|
|
Loading…
Reference in a new issue