mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-16 05:23:19 +01:00
check for enable if an action triggered from keyboard and show hint if disabled
This commit is contained in:
parent
65a822ba5a
commit
de09216be1
3 changed files with 38 additions and 7 deletions
|
|
@ -1,9 +1,12 @@
|
|||
import {createToken} from 'bus';
|
||||
import {enableAnonymousActionHint} from "./anonHint";
|
||||
|
||||
export function activate(context) {
|
||||
|
||||
let {bus} = context;
|
||||
|
||||
let showAnonymousActionHint = enableAnonymousActionHint(context);
|
||||
|
||||
function run(id, data) {
|
||||
bus.dispatch(TOKENS.actionRun(id), data);
|
||||
}
|
||||
|
|
@ -38,7 +41,13 @@ export function activate(context) {
|
|||
bus.subscribe(event, stateUpdater);
|
||||
}
|
||||
}
|
||||
bus.subscribe(TOKENS.actionRun(action.id), (data) => action.invoke(context, data));
|
||||
bus.subscribe(TOKENS.actionRun(action.id), data => {
|
||||
if (bus.state[stateToken].enabled) {
|
||||
action.invoke(context, data)
|
||||
} else {
|
||||
showAnonymousActionHint(action.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bus.enableState(TOKENS.HINT, null);
|
||||
|
|
@ -51,7 +60,7 @@ export function activate(context) {
|
|||
}
|
||||
|
||||
synchActionHint(bus);
|
||||
|
||||
|
||||
context.services.action = {run, registerAction, registerActions}
|
||||
}
|
||||
|
||||
|
|
|
|||
22
web/app/cad/actions/anonHint.js
Normal file
22
web/app/cad/actions/anonHint.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import {TOKENS} from "./actionSystemPlugin";
|
||||
|
||||
export function enableAnonymousActionHint({bus, services}) {
|
||||
|
||||
let autoHideCanceled = true;
|
||||
bus.subscribe(TOKENS.SHOW_HINT_FOR, () => autoHideCanceled = true);
|
||||
|
||||
return function(actionId) {
|
||||
let {left, top} = services.dom.viewerContainer.getBoundingClientRect();
|
||||
bus.dispatch(TOKENS.SHOW_HINT_FOR, {
|
||||
actionId,
|
||||
x: left + 100,
|
||||
y: top + 10
|
||||
});
|
||||
autoHideCanceled = false;
|
||||
setTimeout(() => {
|
||||
if (!autoHideCanceled) {
|
||||
bus.dispatch(TOKENS.SHOW_HINT_FOR, null);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
export default {
|
||||
'CUT': 'C',
|
||||
'EXTRUDE': 'E',
|
||||
'CUT': 'c',
|
||||
'EXTRUDE': 'e',
|
||||
'ZoomIn': '+',
|
||||
'ZoomOut': '-',
|
||||
'menu.craft': 'shift+C',
|
||||
'menu.primitives': 'shift+A',
|
||||
'menu.craft': 'shift+c',
|
||||
'menu.primitives': 'shift+a',
|
||||
'menu.main': 'space',
|
||||
'Save': 'ctrl+S',
|
||||
'Save': 'ctrl+s',
|
||||
'Info': 'F1',
|
||||
'DebugOpenBrepDebugger': 'ctrl+b'
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue