修改lz zc 等鼠标事件统一接口处理

This commit is contained in:
ival 2019-08-07 09:16:55 +08:00
parent a02a948f17
commit 3751748979
10 changed files with 89 additions and 145 deletions

View File

@ -10,7 +10,6 @@ export default class EMouse extends Group {
}
create() {
this.text = new Text({
_subType: 'Text',
zlevel: this.device.zlevel,
z: this.device.z+1,
position: [0, 0],
@ -29,32 +28,27 @@ export default class EMouse extends Group {
this.add(this.text);
this.text.hide();
}
mouseoverText(e) {
this.text.show();
}
mouseoutText(e) {
if (!this.down) {
this.text.hide();
mouseover(e) {
if (e.target && e.target._subType == 'Text') {
this.text.show();
} else {
this.device.control.setControlColor(this.device.style.LcControl.mouseOverStyle.arcColor);
this.device.control.setTextColor(this.device.style.LcControl.mouseOverStyle.textColor);
this.device.control.setTextBorder(true);
this.device.control.setArcBorder(true);
}
}
mouseoverArc(e) {
this.device.control.setControlColor(this.device.style.LcControl.mouseOverStyle.arcColor);
this.device.control.setTextColor(this.device.style.LcControl.mouseOverStyle.textColor);
this.device.control.setTextBorder(true);
this.device.control.setArcBorder(true);
}
mouseoutArc(e) {
if (!this.down) {
this.device.control.setControlColor(this.device.style.LcControl.lamp.controlColor);
this.device.control.setTextColor('#FFFFFF');
this.device.control.setTextBorder(false);
this.device.control.setArcBorder(false);
}
}
mouseout(e) {
this.mouseoutText(e);
this.mouseoutArc(e);
if (!this.down) {
if (e.target && e.target._subType == 'Text') {
this.text.hide();
} else {
this.device.control.setControlColor(this.device.style.LcControl.lamp.controlColor);
this.device.control.setTextColor('#FFFFFF');
this.device.control.setTextBorder(false);
this.device.control.setArcBorder(false);
}
}
}
}

View File

@ -14,8 +14,9 @@ export default class LcControl extends Group {
this.zlevel = model.zlevel;
this.model = model;
this.style = style;
this.createMouseEvent();
this.create();
this.createMouseEvent();
this.setState(model);
}
create() {
@ -30,9 +31,7 @@ export default class LcControl extends Group {
r: this.style.LcControl.lamp.radiusR
},
lineWidth: 0,
fill: this.style.LcControl.lamp.controlColor,
mouseover: this.mouseoverArc,
mouseout: this.mouseoutArc
fill: this.style.LcControl.lamp.controlColor
},
text: {
position: [0, 0],
@ -44,15 +43,12 @@ export default class LcControl extends Group {
text: model.name,
textFill: '#fff',
textAlign: 'middle',
textVerticalAlign: 'top',
mouseover: this.mouseoverText,
mouseout: this.mouseoutText
textVerticalAlign: 'top'
},
style: this.style
});
this.add(this.control);
this.setState(model);
}
// 设置状态
@ -63,18 +59,8 @@ export default class LcControl extends Group {
if (this.style.LcControl.mouseOverStyle) {
this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent);
this.mouseoverText = (e) => {
this.mouseEvent.mouseoverText(e);
};
this.mouseoutText = (e) => {
this.mouseEvent.mouseoutText(e);
};
this.mouseoverArc = (e) => {
this.mouseEvent.mouseoverArc(e);
};
this.mouseoutArc = (e) => {
this.mouseEvent.mouseoutArc(e);
};
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
}
}

View File

@ -29,32 +29,27 @@ export default class EMouse extends Group {
this.add(this.text);
this.text.hide();
}
mouseoverText(e) {
this.text.show();
}
mouseoutText(e) {
if (!this.down) {
this.text.hide();
mouseover(e) {
if (e.target && e.target._subType == 'Text') {
this.text.show();
} else {
this.device.control.setControlColor(this.device.style.LimitControl.mouseOverStyle.arcColor);
this.device.control.setTextColor(this.device.style.LimitControl.mouseOverStyle.textColor);
this.device.control.setTextBorder(true);
this.device.control.setArcBorder(true);
}
}
mouseoverArc(e) {
this.device.control.setControlColor(this.device.style.LimitControl.mouseOverStyle.arcColor);
this.device.control.setTextColor(this.device.style.LimitControl.mouseOverStyle.textColor);
this.device.control.setTextBorder(true);
this.device.control.setArcBorder(true);
}
mouseoutArc(e) {
if (!this.down) {
this.device.control.setControlColor(this.device.style.LimitControl.lamp.controlColor);
this.device.control.setTextColor('#FFFFFF');
this.device.control.setTextBorder(false);
this.device.control.setArcBorder(false);
}
}
mouseout(e) {
this.mouseoutText(e);
this.mouseoutArc(e);
if (!this.down) {
if (e.target && e.target._subType == 'Text') {
this.text.hide();
} else {
this.device.control.setControlColor(this.device.style.LimitControl.lamp.controlColor);
this.device.control.setTextColor('#FFFFFF');
this.device.control.setTextBorder(false);
this.device.control.setArcBorder(false);
}
}
}
}

View File

@ -15,8 +15,9 @@ export default class LimitControl extends Group {
this.model = model;
this.style = style;
this.z = 20;
this.createMouseEvent();
this.create(model);
this.createMouseEvent();
this.setState(model);
}
create(model) {
@ -52,7 +53,6 @@ export default class LimitControl extends Group {
});
this.add(this.control);
this.setState(this.model);
}
// 设置状态
@ -63,18 +63,8 @@ export default class LimitControl extends Group {
if (this.style.LimitControl.mouseOverStyle) {
this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent);
this.mouseoverText = (e) => {
this.mouseEvent.mouseoverText(e);
};
this.mouseoutText = (e) => {
this.mouseEvent.mouseoutText(e);
};
this.mouseoverArc = (e) => {
this.mouseEvent.mouseoverArc(e);
};
this.mouseoutArc = (e) => {
this.mouseEvent.mouseoutArc(e);
};
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
}
}

View File

@ -162,12 +162,8 @@ class Signal extends Group {
if (this.style.Signal.mouseOverStyle) {
this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent);
this.onmouseover = (e) => {
this.mouseEvent.mouseover(e);
};
this.onmouseout = (e) => {
this.mouseEvent.mouseout(e);
};
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
}
}

View File

@ -36,21 +36,23 @@ export default class EMouse extends Group {
}
}
mouseover(e) {
let name = '';
switch (e.target.parent._subType) {
case 'emergency':
name = '紧急站控';
break;
case 'center':
name = '中控';
break;
case 'substation':
name = '站控';
break;
if (e.target) {
let name = '';
switch (e.target.parent._subType) {
case 'emergency':
name = '紧急站控';
break;
case 'center':
name = '中控';
break;
case 'substation':
name = '站控';
break;
}
// debugger;
this.setTextContext(name);
this.text.show();
}
// debugger;
this.setTextContext(name);
this.text.show();
}
mouseout(e) {

View File

@ -142,8 +142,8 @@ export default class StationControl extends Group {
if (this.style.ZcControl.mouseOverStyle) {
this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent);
this.onmouseover = (e) => { this.mouseEvent.mouseover(e); };
this.onmouseout = (e) => { this.mouseEvent.mouseout(e); };
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
}
}
getShapeTipPoint() {

View File

@ -169,12 +169,8 @@ class StationStand extends Group {
if (this.style.StationStand.mouseOverStyle) {
this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent);
this.onmouseover = (e) => {
this.mouseEvent.mouseover(e);
};
this.onmouseout = (e) => {
this.mouseEvent.mouseout(e);
};
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
}
}

View File

@ -29,32 +29,27 @@ export default class EMouse extends Group {
this.add(this.text);
this.text.hide();
}
mouseoverText(e) {
this.text.show();
}
mouseoutText(e) {
if (!this.down) {
this.text.hide();
mouseover(e) {
if (e.target && e.target._subType == 'Text') {
this.text.show();
} else {
this.device.control.setControlColor(this.device.style.ZcControl.mouseOverStyle.arcColor);
this.device.control.setTextColor(this.device.style.ZcControl.mouseOverStyle.textColor);
this.device.control.setTextBorder(true);
this.device.control.setArcBorder(true);
}
}
mouseoverArc(e) {
this.device.control.setControlColor(this.device.style.ZcControl.mouseOverStyle.arcColor);
this.device.control.setTextColor(this.device.style.ZcControl.mouseOverStyle.textColor);
this.device.control.setTextBorder(true);
this.device.control.setArcBorder(true);
}
mouseoutArc(e) {
if (!this.down) {
this.device.control.setControlColor(this.device.style.ZcControl.lamp.controlColor);
this.device.control.setTextColor('#FFFFFF');
this.device.control.setTextBorder(false);
this.device.control.setArcBorder(false);
}
}
mouseout(e) {
this.mouseoutText(e);
this.mouseoutArc(e);
if (!this.down) {
if (e.target && e.target._subType == 'Text') {
this.text.hide();
} else {
this.device.control.setControlColor(this.device.style.ZcControl.lamp.controlColor);
this.device.control.setTextColor('#FFFFFF');
this.device.control.setTextBorder(false);
this.device.control.setArcBorder(false);
}
}
}
}

View File

@ -14,8 +14,8 @@ export default class ZcControl extends Group {
this.zlevel = model.zlevel;
this.model = model;
this.style = style;
this.createMouseEvent();
this.create(model);
this.createMouseEvent();
this.setState(model);
}
@ -62,18 +62,8 @@ export default class ZcControl extends Group {
if (this.style.ZcControl.mouseOverStyle) {
this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent);
this.mouseoverText = (e) => {
this.mouseEvent.mouseoverText(e);
};
this.mouseoutText = (e) => {
this.mouseEvent.mouseoutText(e);
};
this.mouseoverArc = (e) => {
this.mouseEvent.mouseoverArc(e);
};
this.mouseoutArc = (e) => {
this.mouseEvent.mouseoutArc(e);
};
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
}
}
getShapeTipPoint() {