From db66c2d42184524de985bbf9f5ddc7f44f67c4dc Mon Sep 17 00:00:00 2001 From: PeenScreeker Date: Wed, 18 Sep 2024 23:41:05 -0400 Subject: [PATCH] fix: edit region points via textedit --- scripts/pages/zoning/zoning.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/pages/zoning/zoning.ts b/scripts/pages/zoning/zoning.ts index e4edd4f7..637fd7d7 100644 --- a/scripts/pages/zoning/zoning.ts +++ b/scripts/pages/zoning/zoning.ts @@ -458,10 +458,23 @@ class ZoneMenuHandler { addPointToList(i: number, point: number[]) { const newRegionPoint = $.CreatePanel('Panel', this.panels.pointsList, `Point ${i}`); newRegionPoint.LoadLayoutSnippet('region-point'); - newRegionPoint.FindChildTraverse('PointX').text = point[0].toFixed(2); - newRegionPoint.FindChildTraverse('PointY').text = point[1].toFixed(2); + const deleteButton = newRegionPoint.FindChildTraverse('DeleteButton'); deleteButton.SetPanelEvent('onactivate', () => this.deleteRegionPoint(newRegionPoint)); + + const xText = newRegionPoint.FindChildTraverse('PointX'); + xText.text = point[0].toFixed(2); + xText.SetPanelEvent('ontextentrysubmit', () => { + point[0] = Number.parseFloat(xText.text); + this.updateZones(); + }); + + const yText = newRegionPoint.FindChildTraverse('PointY'); + yText.text = point[1].toFixed(2); + yText.SetPanelEvent('ontextentrysubmit', () => { + point[1] = Number.parseFloat(yText.text); + this.updateZones(); + }); } deleteRegionPoint(point: Panel) {