修正DynamicInput按下Ctrl+Z,Y时焦点转移的问题,

更新依赖
pull/493/MERGE
ChenX 5 years ago
parent 7cabafc94a
commit c075dc9db5

@ -22,7 +22,7 @@
"devDependencies": {
"@types/html-webpack-plugin": "^3.2.1",
"@types/jest": "^24.0.18",
"@types/node": "^12.7.2",
"@types/node": "^12.7.4",
"@types/pako": "^1.0.1",
"@types/react": "^16.9.2",
"@types/react-color": "^3.0.1",
@ -37,7 +37,7 @@
"autoresponsive-react": "^1.1.31",
"cache-loader": "^4.1.0",
"clean-webpack-plugin": "^1.0.1",
"cross-env": "^5.2.0",
"cross-env": "^5.2.1",
"css-loader": "^3.2.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^4.2.0",
@ -59,7 +59,7 @@
"shader-loader": "^1.3.1",
"source-map-loader": "^0.2.4",
"style-loader": "^1.0.0",
"terser-webpack-plugin": "^1.4.1",
"terser-webpack-plugin": "^2.0.1",
"ts-jest": "^24.0.2",
"ts-loader": "^6.0.4",
"ts-node": "^8.3.0",
@ -68,14 +68,14 @@
"url-loader": "^2.1.0",
"wallaby-webpack": "^3.9.15",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.7",
"webpack-cli": "^3.3.8",
"webpack-dev-server": "^3.8.0",
"webpack-merge": "^4.2.2",
"worker-loader": "^2.0.0"
},
"dependencies": {
"@blueprintjs/core": "^3.18.0",
"detect-browser": "^4.6.0",
"@blueprintjs/core": "^3.18.1",
"detect-browser": "^4.7.0",
"dxf-parser": "^1.0.0-alpha.1",
"golden-layout": "^1.5.9",
"mobx": "^5.13.0",

@ -0,0 +1,37 @@
function ActiveElementsWatch()
{
let lastActiveElement = document.activeElement;
function detectBlur()
{
// Do logic related to blur using document.activeElement;
// You can do change detection too using lastActiveElement as a history
}
function isSameActiveElement()
{
let currentActiveElement = document.activeElement;
if (lastActiveElement != currentActiveElement)
{
lastActiveElement = currentActiveElement;
return false;
}
return true;
}
function detectFocus()
{
// Add logic to detect focus and to see if it has changed or not from the lastActiveElement.
console.log(document.activeElement);
}
function attachEvents()
{
window.addEventListener('focus', detectFocus, true);
window.addEventListener('blur', detectBlur, true);
}
attachEvents();
}

@ -16,6 +16,7 @@ export class DynamicInput
UpdateWidth: Function;
//shift按键已经被按下
isShiftDown = false;
isCtrlDown = false;
constructor(container: HTMLElement)
{
this.container = document.createElement("div");
@ -91,6 +92,8 @@ export class DynamicInput
{
switch (e.keyCode as KeyBoard)
{
case KeyBoard.Control:
this.isCtrlDown = true;
case KeyBoard.Escape:
case KeyBoard.Space:
case KeyBoard.Enter:
@ -98,8 +101,6 @@ export class DynamicInput
case KeyBoard.Comma:
e.preventDefault();
return;
case KeyBoard.Control:
return;
//shift + 2 =>@ 切换成相对模式
case KeyBoard.Shift:
this.isShiftDown = true;
@ -115,6 +116,10 @@ export class DynamicInput
break;
}
if (this.isCtrlDown)
if (e.keyCode === KeyBoard.KeyZ || e.keyCode === KeyBoard.KeyZ)
e.preventDefault();
if (e.keyCode !== KeyBoard.F8 && e.keyCode !== KeyBoard.KeyZ && e.keyCode !== KeyBoard.KeyY)
e.stopPropagation();
}
@ -123,6 +128,8 @@ export class DynamicInput
{
if (e.keyCode === KeyBoard.Shift)
this.isShiftDown = false;
else if (e.keyCode === KeyBoard.Control)
this.isCtrlDown = false;
}
//激活焦点

Loading…
Cancel
Save