diff --git a/src/lib/bases/BaseContainer.ts b/src/lib/bases/BaseContainer.ts index 6ddb9c911ffc1734fbe75364593dd7fd3597dbbb..e27c9fa95f7a00c2ac0461469b7f72776992d6fc 100644 --- a/src/lib/bases/BaseContainer.ts +++ b/src/lib/bases/BaseContainer.ts @@ -41,7 +41,9 @@ export abstract class BaseContainer extends PIXI.Container { public getBlockedFilter(): PIXI.filters.ColorMatrixFilter { if (!this._blockedFilter) { this._blockedFilter = new PIXI.filters.ColorMatrixFilter(); - this._blockedFilter.desaturate(); + // this._blockedFilter.desaturate(); + this._blockedFilter.greyscale(0, true); + // this._blockedFilter.night(10, true); // TODO remove this._blockedFilter.vintage(true); } return this._blockedFilter; diff --git a/src/lib/elements/collections/LegendCollection.ts b/src/lib/elements/collections/LegendCollection.ts index 8980d8cb13a579c2efde6f10ec15bf03be4e876e..92758151e8f676d5620bf40f103cc15b35d9c1f5 100644 --- a/src/lib/elements/collections/LegendCollection.ts +++ b/src/lib/elements/collections/LegendCollection.ts @@ -922,6 +922,7 @@ export class LegendCollection extends BaseElementContainer<Models.LegendCollecti this.modeInteraction.changeMode("blocked", undefined); } this.emit("groupSelected", event, groupImageObjects); + this.rotateContainer.emit("groupSelected", event, groupImageObjects); } protected _itemSelected(event: PIXI.interaction.InteractionEvent, element: ImageObject): void { diff --git a/src/lib/elements/collections/LegendColumnCollection.ts b/src/lib/elements/collections/LegendColumnCollection.ts index 53d73db9ed905c659da0779f0e3ef7bfd6d6aa40..012e6938d9b8533e4f6635293493176a9cde093e 100644 --- a/src/lib/elements/collections/LegendColumnCollection.ts +++ b/src/lib/elements/collections/LegendColumnCollection.ts @@ -137,6 +137,7 @@ export class LegendColumnCollection extends BaseContainer { parent.on("setDefaultMode", this._setDefaultMode, this); parent.on("stage-ready", this._stageReady, this); + parent.on("groupSelected", this._groupSelected, this); parent.on("itemSelected", this._itemSelected, this); parent.on("itemSelftest", this._itemSelftest, this); parent.on("itemInteractive", this._itemInteractive, this); @@ -150,6 +151,7 @@ export class LegendColumnCollection extends BaseContainer { parent.off("setDefaultMode", this._setDefaultMode, this); parent.off("stage-ready", this._stageReady, this); + parent.off("groupSelected", this._groupSelected, this); parent.off("itemSelected", this._itemSelected, this); parent.off("itemSelftest", this._itemSelftest, this); parent.off("itemInteractive", this._itemInteractive, this); @@ -213,6 +215,10 @@ export class LegendColumnCollection extends BaseContainer { super.destroy(options); } + public getNumberElement(row: number): PIXI.Text { + return this.rotateContainer.getChildByName(this.index + "_" + row + "_num") as PIXI.Text; + } + public removeRowItem(row: number): void { (this.parent.parent as LegendCollection).removeRowItem(this.index, row); } @@ -226,6 +232,10 @@ export class LegendColumnCollection extends BaseContainer { this.zIndex -= 1000; this.parent.sortChildren(); } + + public getLegendModel(): Models.LegendCollection { + return (this.parent.parent as LegendCollection).model; + } //</editor-fold> //<editor-fold desc="Private functions"> @@ -460,6 +470,17 @@ export class LegendColumnCollection extends BaseContainer { this.modeInteraction.changeMode(this.modeInteraction.defaultMode); } + protected _groupSelected(event: PIXI.interaction.InteractionEvent, groupImageObjects: string[]): void { + if (this.model && this.model.id && groupImageObjects.indexOf(this.model.id) > -1) { + this.modeInteraction.changeMode("group"); + } else { + this.selectInteraction.onRelease(event); + this.modeInteraction.changeMode("blocked", undefined); + } + this.emit("groupSelected", event, groupImageObjects); + this._rotateContainer.emit("groupSelected", event, groupImageObjects); + } + protected _itemSelected(event: PIXI.interaction.InteractionEvent, element: ImageObject): void { if (element !== this) { this.selectInteraction.onRelease(event); @@ -556,7 +577,7 @@ export class LegendColumnCollection extends BaseContainer { } public itemSelected(event: PIXI.interaction.InteractionEvent, element: ImageObject): void { - (this.parent.parent as LegendCollection).itemSelected(event, element, this.parent as LegendCollection); + (this.parent.parent as LegendCollection).itemSelected(event, element, this.parent.parent as LegendCollection); } public itemSelftest(event: PIXI.interaction.InteractionEvent, element: ImageObject): void { diff --git a/src/lib/elements/images/MedsurfSprite.ts b/src/lib/elements/images/MedsurfSprite.ts index d6032f6e64f908d6a88189dcb6dddec8bc9124a3..a7f504772dc5afef1574fd350a04c61060920c17 100644 --- a/src/lib/elements/images/MedsurfSprite.ts +++ b/src/lib/elements/images/MedsurfSprite.ts @@ -13,8 +13,7 @@ import {EllipsePrimitiveGenerator} from "../../generators/EllipsePrimitiveGenera import {TextPrimitiveGenerator} from "../../generators/TextPrimitiveGenerator"; import {LineGenerator} from "../../generators/LineGenerator"; import {ModeInteraction} from "../../interactions/ModeInteraction"; -import {FillCollection, PositionPoint} from "../.."; -import {Line} from "../.."; +import {PositionPoint, Line} from "../.."; import {PolygonGenerator} from "../../generators/PolygonGenerator"; import {FillPolygonGenerator} from "../../generators/FillPolygonGenerator"; import {MarkerGenerator} from "../../generators/MarkerGenerator"; @@ -92,7 +91,6 @@ export class MedsurfSprite extends BaseSprite { /** * Design */ - protected readonly _groupPad: number = 10; protected readonly _visiblePad: number = 10; protected readonly _visibleImageXAspect: number = 10; protected readonly _visibleImageYAspect: number = 10; @@ -835,72 +833,41 @@ export class MedsurfSprite extends BaseSprite { throw "Don't use this"; } + public groupReselect(event: PIXI.interaction.InteractionEvent, groupImageObjects: string[]) { + this.emit("groupSelected", event, groupImageObjects); + this._groupSelectElement.showItem(); + this._groupSelected = true; + this._itemSelected = false; + } + public itemSelected(event: PIXI.interaction.InteractionEvent, element: ImageObject, parentElement: ImageObject): void { event.stopPropagation(); - let groupImageObjects: string[] = []; - for (const g of this._groups) { - const group = g as Models.LayerGroup; - const tmpImageObjects = group.layerImageObjects ? group.layerImageObjects.map(io => io.imageObject) || [] : []; + if (this._groupSelectElement.groupImageObjects.length === 0) { + for (const g of this._groups) { + const group = g as Models.LayerGroup; + const tmpImageObjects = group.layerImageObjects ? group.layerImageObjects.map(io => io.imageObject) || [] : []; + // @ts-ignore + if(tmpImageObjects.filter(id => id === parentElement.model.id)[0]) { + this._groupSelectElement.groupImageObjects = tmpImageObjects; + break; + } + } + } else { // @ts-ignore - if(tmpImageObjects.filter(id => id === parentElement.model.id)[0]) { - groupImageObjects = tmpImageObjects; - break; + if(!(this._groupSelectElement.groupImageObjects.filter(id => id === parentElement.model.id)[0])) { + this._groupSelectElement.groupImageObjects = []; } } - if (groupImageObjects.length > 0) { + if (this._groupSelectElement.groupImageObjects.length > 0) { if (!this._groupSelected) { - let topLeft: PIXI.Point; - let topRight: PIXI.Point; - let bottomLeft: PIXI.Point; - groupImageObjects.forEach((id: string) => { - const element = this.getChildByName(id) as ImageObject; - const rect = element.getSelectRectangle(); - - if (!topLeft) { - topLeft = new PIXI.Point(rect.x, rect.y); - } else { - if (rect.x < topLeft.x) { - topLeft.x = rect.x; - } - if (rect.y < topLeft.y) { - topLeft.y = rect.y; - } - } - - if (!topRight) { - topRight = new PIXI.Point(rect.x + rect.width); - } else { - if (rect.x + rect.width > topRight.x) { - topRight.x = rect.x + rect.width; - } - } - - if (!bottomLeft) { - bottomLeft = new PIXI.Point(undefined, rect.y + rect.height); - } else { - if (rect.y + rect.height > bottomLeft.y) { - bottomLeft.y = rect.y + rect.height; - } - } - }); - - this.emit("groupSelected", event, groupImageObjects); - - this._groupSelectElement.rectangle = new PIXI.Rectangle( - // @ts-ignore - topLeft.x - this._groupPad, - // @ts-ignore - topLeft.y - this._groupPad, - // @ts-ignore - topRight.x - topLeft.x + 2 * this._groupPad, - // @ts-ignore - bottomLeft.y - topLeft.y + 2 * this._groupPad - ); + this.emit("groupSelected", event, this._groupSelectElement.groupImageObjects); + this._groupSelectElement.showItem(); this._groupSelected = true; } else { + // this.emit("groupSelected", event, groupImageObjects); this.emit("itemSelected", event, element); this._groupSelected = true; @@ -958,6 +925,7 @@ export class MedsurfSprite extends BaseSprite { this.emit("allElementRelease", event); + this._groupSelectElement.groupImageObjects = []; this._groupSelectElement.hideItem(); this._groupSelected = false; this._itemSelected = false; diff --git a/src/lib/elements/interactions/select/SelectElement.ts b/src/lib/elements/interactions/select/SelectElement.ts index 4ab60f4cb29307dd1e26c1eaed169dceb047a3af..1719ebaf28aea3d44c9f06e01a206e14f4675445 100644 --- a/src/lib/elements/interactions/select/SelectElement.ts +++ b/src/lib/elements/interactions/select/SelectElement.ts @@ -1,5 +1,5 @@ import * as PIXI from "pixi.js-legacy"; -import {BaseContainer} from "../../../bases/BaseModul"; +import {BaseContainer, ImageObject} from "../../../bases/BaseModul"; /** * Select element @@ -8,7 +8,8 @@ export class SelectElement extends BaseContainer { /** * Members */ - private _rectangle: PIXI.Rectangle; + private _groupImageObjects: string[]; + protected _rectangle: PIXI.Rectangle; protected _lineColor: number; protected _fillColor: number; @@ -23,7 +24,8 @@ export class SelectElement extends BaseContainer { /** * Design */ - protected readonly _rectangleDefault = new PIXI.Rectangle(0, 0, 10, 10); + protected readonly _groupPad: number = 10; + // TODO remove protected readonly _rectangleDefault = new PIXI.Rectangle(0, 0, 10, 10); protected readonly _lineWidth: number = 1; protected readonly _lineColorNormal: number = 0x4a90e2; protected readonly _lineAlpha: number = 1; @@ -32,14 +34,14 @@ export class SelectElement extends BaseContainer { /** * Constructor - * @param rectangle + * @param groupImageObjects */ - public constructor(rectangle?: PIXI.Rectangle) { + public constructor(groupImageObjects: string[] = []) { super(); // Setup this.zIndex = 50; - this._rectangle = rectangle || this._rectangleDefault; + this._groupImageObjects = groupImageObjects; this._lineColor = this._lineColorNormal; this._fillColor = this._fillColorNormal; @@ -55,52 +57,95 @@ export class SelectElement extends BaseContainer { this._leftLineElement = new PIXI.Graphics(); this.addChild(this._leftLineElement); - - // Events - this.interactive = true; - this.on("pointerdown", this._onPointerDown, this); - this.on("rightup", this._onRightUp, this); } //<editor-fold desc="Public functions"> public draw(): void { this._topLineElement.clear(); this._topLineElement.lineStyle(this._lineWidth, this._lineColor, this._lineAlpha); - this._topLineElement.moveTo(this.rectangle.x, this.rectangle.y); - this._topLineElement.lineTo(this.rectangle.x + this.rectangle.width, this.rectangle.y); + this._topLineElement.moveTo(this._rectangle.x, this._rectangle.y); + this._topLineElement.lineTo(this._rectangle.x + this._rectangle.width, this._rectangle.y); this._topLineElement.endFill(); this._topLineElement.hitArea = this._topLineElement.getLocalBounds(); this._rightLineElement.clear(); this._rightLineElement.lineStyle(this._lineWidth, this._lineColor, this._lineAlpha); - this._rightLineElement.moveTo(this.rectangle.x + this.rectangle.width, this.rectangle.y); - this._rightLineElement.lineTo(this.rectangle.x + this.rectangle.width, this.rectangle.y + this.rectangle.height); + this._rightLineElement.moveTo(this._rectangle.x + this._rectangle.width, this._rectangle.y); + this._rightLineElement.lineTo(this._rectangle.x + this._rectangle.width, this._rectangle.y + this._rectangle.height); this._rightLineElement.endFill(); this._rightLineElement.hitArea = this._rightLineElement.getLocalBounds(); this._bottomLineElement.clear(); this._bottomLineElement.lineStyle(this._lineWidth, this._lineColor, this._lineAlpha); - this._bottomLineElement.moveTo(this.rectangle.x, this.rectangle.y + this.rectangle.height); - this._bottomLineElement.lineTo(this.rectangle.x + this.rectangle.width, this.rectangle.y + this.rectangle.height); + this._bottomLineElement.moveTo(this._rectangle.x, this._rectangle.y + this._rectangle.height); + this._bottomLineElement.lineTo(this._rectangle.x + this._rectangle.width, this._rectangle.y + this._rectangle.height); this._bottomLineElement.endFill(); this._bottomLineElement.hitArea = this._bottomLineElement.getLocalBounds(); this._leftLineElement.clear(); this._leftLineElement.lineStyle(this._lineWidth, this._lineColor, this._lineAlpha); - this._leftLineElement.moveTo(this.rectangle.x, this.rectangle.y); - this._leftLineElement.lineTo(this.rectangle.x, this.rectangle.y + this.rectangle.height); + this._leftLineElement.moveTo(this._rectangle.x, this._rectangle.y); + this._leftLineElement.lineTo(this._rectangle.x, this._rectangle.y + this._rectangle.height); this._leftLineElement.endFill(); this._leftLineElement.hitArea = this._leftLineElement.getLocalBounds(); - this.hitArea = this.rectangle; + this.hitArea = this._rectangle; } //</editor-fold> //<editor-fold desc="Private functions"> + protected _calculateRectangle(): void { + let topLeft: PIXI.Point; + let topRight: PIXI.Point; + let bottomLeft: PIXI.Point; + this.groupImageObjects.forEach((id: string) => { + const element = this.getImage().getChildByName(id) as ImageObject; + const rect = element.getSelectRectangle(); + + if (!topLeft) { + topLeft = new PIXI.Point(rect.x, rect.y); + } else { + if (rect.x < topLeft.x) { + topLeft.x = rect.x; + } + if (rect.y < topLeft.y) { + topLeft.y = rect.y; + } + } + + if (!topRight) { + topRight = new PIXI.Point(rect.x + rect.width); + } else { + if (rect.x + rect.width > topRight.x) { + topRight.x = rect.x + rect.width; + } + } + + if (!bottomLeft) { + bottomLeft = new PIXI.Point(undefined, rect.y + rect.height); + } else { + if (rect.y + rect.height > bottomLeft.y) { + bottomLeft.y = rect.y + rect.height; + } + } + }); + + this._rectangle = new PIXI.Rectangle( + // @ts-ignore + topLeft.x - this._groupPad, + // @ts-ignore + topLeft.y - this._groupPad, + // @ts-ignore + topRight.x - topLeft.x + 2 * this._groupPad, + // @ts-ignore + bottomLeft.y - topLeft.y + 2 * this._groupPad + ); + } + protected _onPointerDown(event: PIXI.interaction.InteractionEvent): void { event.stopPropagation(); - // TODO unselect item -> How to + this.getImage().groupReselect(event, this.groupImageObjects); } protected _onRightUp(event: PIXI.interaction.InteractionEvent): void { @@ -117,21 +162,34 @@ export class SelectElement extends BaseContainer { public showItem(): void { this.renderable = true; + + // Events + this.interactive = true; + this.on("pointerdown", this._onPointerDown, this); + this.on("rightup", this._onRightUp, this); } public hideItem(): void { this.renderable = false; + + // Events + this.interactive = false; + this.off("pointerdown", this._onPointerDown, this); + this.off("rightup", this._onRightUp, this); } //</editor-fold> //<editor-fold desc="Getter and Setter"> - public get rectangle(): PIXI.Rectangle { - return this._rectangle; + public get groupImageObjects(): string[] { + return this._groupImageObjects; } - public set rectangle(value: PIXI.Rectangle) { - this._rectangle = value; - this.draw(); + public set groupImageObjects(value: string[]) { + this._groupImageObjects = value; + if (this._groupImageObjects.length > 0) { + this._calculateRectangle(); + this.draw(); + } } //</editor-fold> } \ No newline at end of file diff --git a/src/lib/elements/primitives/ArrowPrimitive.ts b/src/lib/elements/primitives/ArrowPrimitive.ts index 5905a24909b97fa964db28e3de3f94c7427e38de..816612ad02565207fe5b5d726e0f43dfe6100295 100644 --- a/src/lib/elements/primitives/ArrowPrimitive.ts +++ b/src/lib/elements/primitives/ArrowPrimitive.ts @@ -24,6 +24,7 @@ import {FillCollection} from "../collections/FillCollection"; import {LegendTextPrimitive} from "./LegendTextPrimitive"; import {PointElement} from "../interactions/point/PointElement"; import {NumberElement} from "../interactions/number/NumberElement"; +import {SaveableImageObject} from "../elements"; /** * Arrow primitive @@ -903,7 +904,8 @@ export class ArrowPrimitive extends BaseElementContainer<Models.ArrowPrimitive> } protected _groupSelected(event: PIXI.interaction.InteractionEvent, groupImageObjects: string[]): void { - if (this.model && this.model.id && groupImageObjects.indexOf(this.model.id) > -1) { + const parentModel = (this.parent as SaveableImageObject).model; + if (parentModel && parentModel.id && groupImageObjects.indexOf(parentModel.id) > -1) { this.modeInteraction.changeMode("group"); } else { this.selectInteraction.onRelease(event); diff --git a/src/lib/elements/primitives/EllipsePrimitive.ts b/src/lib/elements/primitives/EllipsePrimitive.ts index 2d45c749b20772574fe1aff5c6f54e9a5aee4be0..dbc2d8d539493d53466d686133051589a833f3f9 100644 --- a/src/lib/elements/primitives/EllipsePrimitive.ts +++ b/src/lib/elements/primitives/EllipsePrimitive.ts @@ -23,6 +23,7 @@ import {ArrowPrimitive} from "./ArrowPrimitive"; import {FillCollection} from "../collections/FillCollection"; import {LegendTextPrimitive} from "./LegendTextPrimitive"; import {NumberElement} from "../interactions/number/NumberElement"; +import {SaveableImageObject} from "../elements"; /** * Ellipse primitive @@ -844,7 +845,8 @@ export class EllipsePrimitive extends BaseElementContainer<Models.EllipsePrimiti } protected _groupSelected(event: PIXI.interaction.InteractionEvent, groupImageObjects: string[]): void { - if (this.model && this.model.id && groupImageObjects.indexOf(this.model.id) > -1) { + const parentModel = (this.parent as SaveableImageObject).model; + if (parentModel && parentModel.id && groupImageObjects.indexOf(parentModel.id) > -1) { this.modeInteraction.changeMode("group"); } else { this.selectInteraction.onRelease(event); diff --git a/src/lib/elements/primitives/LegendTextPrimitive.ts b/src/lib/elements/primitives/LegendTextPrimitive.ts index bbde72f6fdacffa4784147ae4151886bfdac39aa..d511ba61d6c44eb2595023602ee12c5df916f0c1 100644 --- a/src/lib/elements/primitives/LegendTextPrimitive.ts +++ b/src/lib/elements/primitives/LegendTextPrimitive.ts @@ -24,6 +24,7 @@ import {LegendColumnCollection} from "../collections/LegendColumnCollection"; import {FillCollection} from "../collections/FillCollection"; import {LegendCollection} from "../collections/LegendCollection"; import {NumberElement} from "../interactions/number/NumberElement"; +import {SaveableImageObject} from "../elements"; /** @@ -312,6 +313,10 @@ export class LegendTextPrimitive extends BaseElementContainer<Models.LegendItem> this.cleanUp(); super.destroy(options); } + + public getLegendModel(): Models.LegendCollection { + return (this.parent.parent as LegendColumnCollection).getLegendModel(); + } //</editor-fold> //<editor-fold desc="Private functions"> @@ -490,7 +495,9 @@ export class LegendTextPrimitive extends BaseElementContainer<Models.LegendItem> this._style.fill = this._fillColorSelftestSelected; this.draw(); } else { - this.filters = [this.getBlockedFilter()]; + const filter = this.getBlockedFilter(); + this.filters = [filter]; + (this.parent.parent as LegendColumnCollection).getNumberElement(this.index).filters = [filter]; } // Events @@ -505,6 +512,7 @@ export class LegendTextPrimitive extends BaseElementContainer<Models.LegendItem> this.draw(); this.filters = []; + (this.parent.parent as LegendColumnCollection).getNumberElement(this.index).filters = []; // Events this.interactive = false; @@ -531,7 +539,10 @@ export class LegendTextPrimitive extends BaseElementContainer<Models.LegendItem> protected _modeDrawing(): void { this.removeAllListeners("pointerup"); // TODO dirty fix for adding lines - this.filters = [this.getBlockedFilter()]; + + const filter = this.getBlockedFilter(); + this.filters = [filter]; + (this.parent.parent as LegendColumnCollection).getNumberElement(this.index).filters = [filter]; // Events this.interactive = true; @@ -540,6 +551,7 @@ export class LegendTextPrimitive extends BaseElementContainer<Models.LegendItem> protected _removeModeDrawing(): void { this.filters = []; + (this.parent.parent as LegendColumnCollection).getNumberElement(this.index).filters = []; // Events this.interactive = false; @@ -593,12 +605,17 @@ export class LegendTextPrimitive extends BaseElementContainer<Models.LegendItem> protected _modeFillChoosing(): void { this.removeAllListeners("pointerup"); // TODO dirty fix for adding lines - this.filters = [this.getBlockedFilter()]; + const filter = this.getBlockedFilter(); + this.filters = [filter]; + (this.parent.parent as LegendColumnCollection).getNumberElement(this.index).filters = [filter]; + this.alpha = 0.4; } protected _removeFillModeChoosing(): void { this.filters = []; + (this.parent.parent as LegendColumnCollection).getNumberElement(this.index).filters = []; + this.alpha = 1; } @@ -679,7 +696,8 @@ export class LegendTextPrimitive extends BaseElementContainer<Models.LegendItem> } protected _groupSelected(event: PIXI.interaction.InteractionEvent, groupImageObjects: string[]): void { - if (this.model && this.model.id && groupImageObjects.indexOf(this.model.id) > -1) { + const parentModel = this.getLegendModel(); + if (parentModel && parentModel.id && groupImageObjects.indexOf(parentModel.id) > -1) { this.modeInteraction.changeMode("group"); } else { this.selectInteraction.onRelease(event); diff --git a/src/lib/elements/primitives/RectanglePrimitive.ts b/src/lib/elements/primitives/RectanglePrimitive.ts index c78d57aabb6c5d0db6f70d23cbcff947e5d2e4c3..ef4bbe6db9b444a548cb9fe5e36b59769a728d8f 100644 --- a/src/lib/elements/primitives/RectanglePrimitive.ts +++ b/src/lib/elements/primitives/RectanglePrimitive.ts @@ -23,6 +23,7 @@ import {ArrowPrimitive} from "./ArrowPrimitive"; import {FillCollection} from "../collections/FillCollection"; import {LegendTextPrimitive} from "./LegendTextPrimitive"; import {NumberElement} from "../interactions/number/NumberElement"; +import {SaveableImageObject} from "../elements"; /** * Rectangle primitive @@ -846,7 +847,8 @@ export class RectanglePrimitive extends BaseElementContainer<Models.RectanglePri } protected _groupSelected(event: PIXI.interaction.InteractionEvent, groupImageObjects: string[]): void { - if (this.model && this.model.id && groupImageObjects.indexOf(this.model.id) > -1) { + const parentModel = (this.parent as SaveableImageObject).model; + if (parentModel && parentModel.id && groupImageObjects.indexOf(parentModel.id) > -1) { this.modeInteraction.changeMode("group"); } else { this.selectInteraction.onRelease(event); diff --git a/src/lib/elements/primitives/TextPrimitive.ts b/src/lib/elements/primitives/TextPrimitive.ts index d417aecf48f660799e14a9c11c7820f3b34b1f02..1d36c0dce4adee08f010220a22f5ff55b1db2fde 100644 --- a/src/lib/elements/primitives/TextPrimitive.ts +++ b/src/lib/elements/primitives/TextPrimitive.ts @@ -26,6 +26,7 @@ import {ArrowPrimitive} from "./ArrowPrimitive"; import {LegendTextPrimitive} from "./LegendTextPrimitive"; import {FillCollection} from "../collections/FillCollection"; import {NumberElement} from "../interactions/number/NumberElement"; +import {SaveableImageObject} from "../elements"; /** * Text primitive @@ -978,7 +979,8 @@ export class TextPrimitive extends BaseElementContainer<Models.TextPrimitive> { } protected _groupSelected(event: PIXI.interaction.InteractionEvent, groupImageObjects: string[]): void { - if (this.model && this.model.id && groupImageObjects.indexOf(this.model.id) > -1) { + const parentModel = (this.parent as SaveableImageObject).model; + if (parentModel && parentModel.id && groupImageObjects.indexOf(parentModel.id) > -1) { this.modeInteraction.changeMode("group"); } else { this.selectInteraction.onRelease(event);