From e99c7a4b73409e35a62d4d8e477fe3d9ce3ae3fe Mon Sep 17 00:00:00 2001 From: bordun Date: Wed, 11 Sep 2019 21:29:58 +0200 Subject: [PATCH] matrix: clone matrix: fix children's value storing --- CHANGELOG.md | 1 + .../app/widgets/matrices/_matrix_base.js | 9 -------- src/client/app/widgets/matrices/keyboard.js | 9 ++++++++ src/client/app/widgets/matrices/matrix.js | 23 +++++++++++++++++++ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79df8135..15ed5a2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - package: broken build from sources on Windows - editor: incorrect position when moving a widget from an edge with the keyboard - modal: prevent touchend event from reaching the inner widgets when opening the container + - matrix: clone matrices not properly storing their children's values - widgets - frames: allow loading local html files without requiring a web server to serve them diff --git a/src/client/app/widgets/matrices/_matrix_base.js b/src/client/app/widgets/matrices/_matrix_base.js index 7cad09ec..0a163f57 100644 --- a/src/client/app/widgets/matrices/_matrix_base.js +++ b/src/client/app/widgets/matrices/_matrix_base.js @@ -11,15 +11,6 @@ module.exports = class _matrix_base extends Container { this.value = [] - this.on('change',(e)=>{ - - if (e.widget === this) return - - this.value[e.widget._index] = e.widget.getValue() - this.changed(e.options) - - }) - if (this.getProp('traversing')) enableTraversingGestures(this.widget) } diff --git a/src/client/app/widgets/matrices/keyboard.js b/src/client/app/widgets/matrices/keyboard.js index d8a44619..641fe74c 100644 --- a/src/client/app/widgets/matrices/keyboard.js +++ b/src/client/app/widgets/matrices/keyboard.js @@ -53,6 +53,15 @@ module.exports = class Keyboard extends _matrix_base { super(options) + this.on('change',(e)=>{ + + if (e.widget === this) return + + this.value[e.widget._index] = e.widget.getValue() + this.changed(e.options) + + }) + var start = parseInt(this.getProp('start')), keys = parseInt(this.getProp('keys')) diff --git a/src/client/app/widgets/matrices/matrix.js b/src/client/app/widgets/matrices/matrix.js index 6fa0ef3d..80b1b888 100644 --- a/src/client/app/widgets/matrices/matrix.js +++ b/src/client/app/widgets/matrices/matrix.js @@ -38,6 +38,29 @@ class Matrix extends _matrix_base { super(options) + this.on('change',(e)=>{ + + if (e.widget === this) return + + if (this.getProp('widgetType') === 'clone') { + + if (e.widget.parent.parent !== this) return + + this.value[e.widget.parent._index] = e.widget.getValue() + + } else { + + if (e.widget.parent !== this) return + + this.value[e.widget._index] = e.widget.getValue() + + + } + + this.changed(e.options) + + }) + this.widget.style.setProperty('--columns', this.getProp('matrix')[0]) this.widget.style.setProperty('--rows', this.getProp('matrix')[1]) this.widget.style.setProperty('--spacing', this.getProp('spacing') + 'rem')