I need to call a JS
function when the spacebar
is pressed in a TextInput
It’s possible?
Thanks!
I need to call a JS
function when the spacebar
is pressed in a TextInput
It’s possible?
Thanks!
You could data-bind to an Observable in JS and use onValueChanged
to detect what’s being written. Here’s a complete, minimal example:
<App>
<JavaScript>
var Observable = require("FuseJS/Observable");
var obs = Observable("");
obs.onValueChanged(module, function(x) {
var lastChar = x.substr(-1);
if (lastChar == " ") {
console.log("space was pressed!");
}
});
module.exports = {
obs: obs
};
</JavaScript>
<TextInput Value="{obs}" Width="240" Height="56" TextColor="#fff">
<Rectangle Color="#18f" />
</TextInput>
</App>
Thanks! Work perfect!