From fd9b5bc5fc61408c15af0b7168360958e5e3d09a Mon Sep 17 00:00:00 2001 From: David Wakelin Date: Mon, 8 Apr 2019 21:04:46 +0100 Subject: [PATCH] Allowed setting of new forceUpdateDisplay property to override default behaviour of preventing updates to active select inputs --- src/dat/controllers/Controller.js | 6 ++++++ src/dat/controllers/OptionController.js | 2 +- src/dat/gui/GUI.js | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/dat/controllers/Controller.js b/src/dat/controllers/Controller.js index b65c774..7c39f61 100644 --- a/src/dat/controllers/Controller.js +++ b/src/dat/controllers/Controller.js @@ -52,6 +52,12 @@ class Controller { * @ignore */ this.__onFinishChange = undefined; + + /** + * Wether to force update a display, even when active. + * @type boolean + */ + this.forceUpdateDisplay = false; } /** diff --git a/src/dat/controllers/OptionController.js b/src/dat/controllers/OptionController.js index b349031..98e5a22 100644 --- a/src/dat/controllers/OptionController.js +++ b/src/dat/controllers/OptionController.js @@ -76,7 +76,7 @@ class OptionController extends Controller { } updateDisplay() { - if (dom.isActive(this.__select)) return this; // prevent number from updating if user is trying to manually update + if (dom.isActive(this.__select) && !this.forceUpdateDisplay) return this; // prevent number from updating if user is trying to manually update this.__select.value = this.getValue(); return super.updateDisplay(); } diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index 972c307..0d9059c 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -974,7 +974,8 @@ function augmentController(gui, li, controller) { * Sets controller to listen for changes on its underlying object. * @return {Controller} */ - listen: function() { + listen: function(forceUpdateDisplay) { + controller.forceUpdateDisplay = !!forceUpdateDisplay; controller.__gui.listen(controller); return controller; },