修改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() { create() {
this.text = new Text({ this.text = new Text({
_subType: 'Text',
zlevel: this.device.zlevel, zlevel: this.device.zlevel,
z: this.device.z+1, z: this.device.z+1,
position: [0, 0], position: [0, 0],
@ -29,32 +28,27 @@ export default class EMouse extends Group {
this.add(this.text); this.add(this.text);
this.text.hide(); this.text.hide();
} }
mouseoverText(e) { mouseover(e) {
this.text.show(); if (e.target && e.target._subType == 'Text') {
} this.text.show();
} else {
mouseoutText(e) { this.device.control.setControlColor(this.device.style.LcControl.mouseOverStyle.arcColor);
if (!this.down) { this.device.control.setTextColor(this.device.style.LcControl.mouseOverStyle.textColor);
this.text.hide(); 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) { mouseout(e) {
this.mouseoutText(e); if (!this.down) {
this.mouseoutArc(e); 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.zlevel = model.zlevel;
this.model = model; this.model = model;
this.style = style; this.style = style;
this.createMouseEvent();
this.create(); this.create();
this.createMouseEvent();
this.setState(model);
} }
create() { create() {
@ -30,9 +31,7 @@ export default class LcControl extends Group {
r: this.style.LcControl.lamp.radiusR r: this.style.LcControl.lamp.radiusR
}, },
lineWidth: 0, lineWidth: 0,
fill: this.style.LcControl.lamp.controlColor, fill: this.style.LcControl.lamp.controlColor
mouseover: this.mouseoverArc,
mouseout: this.mouseoutArc
}, },
text: { text: {
position: [0, 0], position: [0, 0],
@ -44,15 +43,12 @@ export default class LcControl extends Group {
text: model.name, text: model.name,
textFill: '#fff', textFill: '#fff',
textAlign: 'middle', textAlign: 'middle',
textVerticalAlign: 'top', textVerticalAlign: 'top'
mouseover: this.mouseoverText,
mouseout: this.mouseoutText
}, },
style: this.style style: this.style
}); });
this.add(this.control); this.add(this.control);
this.setState(model);
} }
// 设置状态 // 设置状态
@ -63,18 +59,8 @@ export default class LcControl extends Group {
if (this.style.LcControl.mouseOverStyle) { if (this.style.LcControl.mouseOverStyle) {
this.mouseEvent = new EMouse(this); this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent); this.add(this.mouseEvent);
this.mouseoverText = (e) => { this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.mouseEvent.mouseoverText(e); this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
};
this.mouseoutText = (e) => {
this.mouseEvent.mouseoutText(e);
};
this.mouseoverArc = (e) => {
this.mouseEvent.mouseoverArc(e);
};
this.mouseoutArc = (e) => {
this.mouseEvent.mouseoutArc(e);
};
} }
} }

View File

@ -29,32 +29,27 @@ export default class EMouse extends Group {
this.add(this.text); this.add(this.text);
this.text.hide(); this.text.hide();
} }
mouseoverText(e) { mouseover(e) {
this.text.show(); if (e.target && e.target._subType == 'Text') {
} this.text.show();
} else {
mouseoutText(e) { this.device.control.setControlColor(this.device.style.LimitControl.mouseOverStyle.arcColor);
if (!this.down) { this.device.control.setTextColor(this.device.style.LimitControl.mouseOverStyle.textColor);
this.text.hide(); 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) { mouseout(e) {
this.mouseoutText(e); if (!this.down) {
this.mouseoutArc(e); 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.model = model;
this.style = style; this.style = style;
this.z = 20; this.z = 20;
this.createMouseEvent();
this.create(model); this.create(model);
this.createMouseEvent();
this.setState(model);
} }
create(model) { create(model) {
@ -52,7 +53,6 @@ export default class LimitControl extends Group {
}); });
this.add(this.control); this.add(this.control);
this.setState(this.model);
} }
// 设置状态 // 设置状态
@ -63,18 +63,8 @@ export default class LimitControl extends Group {
if (this.style.LimitControl.mouseOverStyle) { if (this.style.LimitControl.mouseOverStyle) {
this.mouseEvent = new EMouse(this); this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent); this.add(this.mouseEvent);
this.mouseoverText = (e) => { this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.mouseEvent.mouseoverText(e); this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
};
this.mouseoutText = (e) => {
this.mouseEvent.mouseoutText(e);
};
this.mouseoverArc = (e) => {
this.mouseEvent.mouseoverArc(e);
};
this.mouseoutArc = (e) => {
this.mouseEvent.mouseoutArc(e);
};
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -29,32 +29,27 @@ export default class EMouse extends Group {
this.add(this.text); this.add(this.text);
this.text.hide(); this.text.hide();
} }
mouseoverText(e) { mouseover(e) {
this.text.show(); if (e.target && e.target._subType == 'Text') {
} this.text.show();
} else {
mouseoutText(e) { this.device.control.setControlColor(this.device.style.ZcControl.mouseOverStyle.arcColor);
if (!this.down) { this.device.control.setTextColor(this.device.style.ZcControl.mouseOverStyle.textColor);
this.text.hide(); 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) { mouseout(e) {
this.mouseoutText(e); if (!this.down) {
this.mouseoutArc(e); 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.zlevel = model.zlevel;
this.model = model; this.model = model;
this.style = style; this.style = style;
this.createMouseEvent();
this.create(model); this.create(model);
this.createMouseEvent();
this.setState(model); this.setState(model);
} }
@ -62,18 +62,8 @@ export default class ZcControl extends Group {
if (this.style.ZcControl.mouseOverStyle) { if (this.style.ZcControl.mouseOverStyle) {
this.mouseEvent = new EMouse(this); this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent); this.add(this.mouseEvent);
this.mouseoverText = (e) => { this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.mouseEvent.mouseoverText(e); this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
};
this.mouseoutText = (e) => {
this.mouseEvent.mouseoutText(e);
};
this.mouseoverArc = (e) => {
this.mouseEvent.mouseoverArc(e);
};
this.mouseoutArc = (e) => {
this.mouseEvent.mouseoutArc(e);
};
} }
} }
getShapeTipPoint() { getShapeTipPoint() {