enable keybindings for unavailable operations -> show info message

this should make it easier to discover what a given keypress was supposed to do (e.g. which operation it triggered)

closes #9896
This commit is contained in:
Martin Raifer
2025-05-15 17:01:30 +02:00
parent c11b661ef3
commit e25af7c05e
6 changed files with 50 additions and 26 deletions
+21 -12
View File
@@ -192,7 +192,6 @@ export function modeSelect(context, selectedIDs) {
};
function loadOperations() {
_operations.forEach(function(operation) {
if (operation.behavior) {
context.uninstall(operation.behavior);
@@ -200,29 +199,39 @@ export function modeSelect(context, selectedIDs) {
});
_operations = Object.values(Operations)
.map(function(o) { return o(context, selectedIDs); })
.filter(function(o) { return o.id !== 'delete' && o.id !== 'downgrade' && o.id !== 'copy'; })
.map(o => o(context, selectedIDs))
.filter(o => o.id !== 'delete' && o.id !== 'downgrade' && o.id !== 'copy')
.concat([
// group copy/downgrade/delete operation together at the end of the list
Operations.operationCopy(context, selectedIDs),
Operations.operationDowngrade(context, selectedIDs),
Operations.operationDelete(context, selectedIDs)
]).filter(function(operation) {
return operation.available();
]);
_operations
.filter(operation => operation.available())
.forEach(operation => {
if (operation.behavior) {
context.install(operation.behavior);
}
});
_operations.forEach(function(operation) {
if (operation.behavior) {
context.install(operation.behavior);
}
});
// unavailable operations: still install keybindings
// to show information message about the unavailability of the operation
_operations
.filter(operation => !operation.available())
.forEach(operation => {
if (operation.behavior) {
operation.behavior.on();
}
});
// remove any displayed menu
context.ui().closeEditMenu();
}
mode.operations = function() {
return _operations;
return _operations.filter(operation => operation.available());
};
@@ -638,7 +647,7 @@ export function modeSelect(context, selectedIDs) {
_focusedVertexIds = null;
_operations.forEach(function(operation) {
_operations.forEach(operation => {
if (operation.behavior) {
context.uninstall(operation.behavior);
}