From b016724d049d17dd1b81d12a3bb1ded58a0b5e48 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 2 Mar 2026 10:28:05 +0100 Subject: [PATCH] modal, file: add `click` option --- src/client/widgets/basics/file.mjs | 3 ++- src/client/widgets/containers/modal.mjs | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/client/widgets/basics/file.mjs b/src/client/widgets/basics/file.mjs index 55f19e0f..81d610b8 100644 --- a/src/client/widgets/basics/file.mjs +++ b/src/client/widgets/basics/file.mjs @@ -19,6 +19,7 @@ export default class File extends Widget { align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, hidePath: {type: 'boolean', value: false, help: 'Set to `true` to only display the filename (the whole path will still be used as value)'}, mode: {type: 'string', value: 'open', choices: ['open', 'save'], help: 'File browser mode'}, + click: {type: 'boolean', value: false, help: 'Set to `true` to activate upon click event instead of tap'}, }, class_specific: { directory: {type: 'string', value: 'auto', help: 'Default browsing directory'}, @@ -50,7 +51,7 @@ export default class File extends Widget { ext = '(' + ext.join('|') + ')' } - this.on('fast-click', (e)=>{ + this.on(this.getProp('click') ? 'click' : 'fast-click', (e)=>{ if (e.capturedByEditor === true) return diff --git a/src/client/widgets/containers/modal.mjs b/src/client/widgets/containers/modal.mjs index d611f46d..1b810164 100644 --- a/src/client/widgets/containers/modal.mjs +++ b/src/client/widgets/containers/modal.mjs @@ -18,7 +18,8 @@ class Modal extends Panel { return super.defaults().extend({ class_specific: { - doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the modal require a double tap to open instead of a single tap'}, + doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the modal require a double tap to open instead of a single tap (allows scrolling when touching the modal button)'}, + click: {type: 'boolean', value: false, help: 'Set to `true` to make the modal open/close upon click event instead of tap (allows scrolling when touching the modal button)'}, }, geometry: { _separator_modal_geometry: 'Modal geometry', @@ -93,7 +94,7 @@ class Modal extends Panel { var closer = DOM.get(this.popup, '.closer')[0] - this.on('draginit',(e)=>{ + this.on(this.getProp('click') ? 'click' : 'draginit',(e)=>{ if ((e.target === this.popup || e.target === closer) && this.value == 1) { this.setValue(0, {sync:true, send:true}) } else if (!this.getProp('doubleTap') && e.target === this.toggle) { @@ -105,7 +106,7 @@ class Modal extends Panel { if (this.getProp('doubleTap')) { doubleTap(this, ()=>{ this.setValue(1, {sync:true, send:true}) - }, {element: this.toggle}) + }, {element: this.toggle, click: this.getProp('click')}) } this.escapeKeyHandler = ((e)=>{