Skip to content

Commit

Permalink
fix: edit region points via textedit
Browse files Browse the repository at this point in the history
  • Loading branch information
PeenScreeker committed Sep 23, 2024
1 parent b72b04e commit 3be4df9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/pages/zoning/zoning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextEntry>('PointX').text = point[0].toFixed(2);
newRegionPoint.FindChildTraverse<TextEntry>('PointY').text = point[1].toFixed(2);

const deleteButton = newRegionPoint.FindChildTraverse('DeleteButton');
deleteButton.SetPanelEvent('onactivate', () => this.deleteRegionPoint(newRegionPoint));

const xText = newRegionPoint.FindChildTraverse<TextEntry>('PointX');
xText.text = point[0].toFixed(2);
xText.SetPanelEvent('ontextentrysubmit', () => {
point[0] = Number.parseFloat(xText.text);
this.updateZones();
});

const yText = newRegionPoint.FindChildTraverse<TextEntry>('PointY');
yText.text = point[1].toFixed(2);
yText.SetPanelEvent('ontextentrysubmit', () => {
point[1] = Number.parseFloat(yText.text);
this.updateZones();
});
}

deleteRegionPoint(point: Panel) {
Expand Down

0 comments on commit 3be4df9

Please sign in to comment.