Skip to content

Commit a0338c3

Browse files
ypiguet-epflMichael Bonani
authored andcommitted
Option for using TextFieldInput class instead of TextField
1 parent a9c88df commit a0338c3

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

block-library-dev.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,4 @@ VPL is started by code in a "load" event listener defined in vpl-main.js. Some c
649649
- `window["vplConfig"]`: can be set to configuration options: `"ignoredCommands"` is an array of command ids which are discarded and not available in the configuration mode
650650
- `window["vplConvertToHTML"]`: `function(json, isVPL3UI)` to convert the content of a .vpl3 (if `isVPL3UI` is false) or a .vpl3ui file (if `isVPL3UI` is true) to a static HTML file
651651
- `window["vplConvertMDToHtml"]`: `function(md)` to convert simple markdown to an html fragment (block-level elements such as h1, p, etc.)
652+
- `window["vplTextFieldInputEvents"]`: `true` to use `input` events of an invisible `<input>` element for text field input; `false` to use `keydown` events; default is `true` for Android, `false` for other platforms

index-classic-template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
<script src="src/vpl-dynamic-help.js"></script>
237237
<script src="src/vpl-keyboard.js"></script>
238238
<script src="src/vpl-textfield.js"></script>
239+
<script src="src/vpl-textfield-input.js"></script>
239240
<script src="src/vpl-kbd-control.js"></script>
240241
<script src="src/vpl-main.js"></script>
241242

index-svg-template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
<script src="src/vpl-dynamic-help.js"></script>
323323
<script src="src/vpl-keyboard.js"></script>
324324
<script src="src/vpl-textfield.js"></script>
325+
<script src="src/vpl-textfield-input.js"></script>
325326
<script src="src/vpl-kbd-control.js"></script>
326327
<script src="src/vpl-main.js"></script>
327328

src/vpl-app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ A3a.vpl.Application.prototype.startTextField = function (options) {
325325
}
326326
this.textField.finish(true);
327327
}
328-
this.textField = new A3a.vpl.TextField(this, options);
328+
this.textField = window["vplTextFieldInputEvents"]
329+
? new A3a.vpl.TextFieldInput(this, options)
330+
: new A3a.vpl.TextField(this, options);
329331
};
330332

331333
/** Translate message using the current language

src/vpl-main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ function vplGetHashOption(key) {
227227
@return {void}
228228
*/
229229
function vplSetup(gui, rootDir) {
230+
231+
// platform-specific options
232+
if (window["vplTextFieldInputEvents"] === undefined) {
233+
// true on Android, false elsewhere
234+
window["vplTextFieldInputEvents"] = navigator.userAgent.indexOf("Android") >= 0;
235+
}
236+
230237
// handle overlays in gui
231238
/** @type {Array.<Object>} */
232239
var helpFragments = [];

0 commit comments

Comments
 (0)