Tab through Fillin fields on tablet

0
Is there a way to force mendix to jump to the next field after pressing ''enter'' on your keyboard on a tablet? Or something simial to induce this behaviour?
asked
3 answers
0

Here's a helper widget that I've used in the past for this exact purpose. It was last used on Mendix 5.16, so I can't guarantee it works perfectly. Please give it a try - you just need to drop one copy of the widget on the page, and it will interpret Enter presses as tabs, moving you to the next input field.

GitHub Repo

Direct link to MPK

answered
1

I think Jasper built a widget that can achieve this:

https://github.com/jaspervanderhoek/mendix-OnEnterInputbox

answered
0

Not by default, probably only possible with some additional javascript or you could request it in the idea forum for a platform implementation.

Javascript (based on jquery) would look something like:

$('input').keydown(function(e){
    if(e.keyCode == 13) {
        var inputElement = $(this);
        var parentForm = inputElement.parents('form');
        var allInputs = parentForm.find('input:visible,select:visible,textarea:visible');

        var preventDefault = true;

        if(allInputs.length > 1) {
            if($(allInputs[allInputs.length-1]).attr('name') == inputElement.attr('name')) {
                preventDefault = false;
            } else {
                for(var i = 0; i < allInputs.length; i++) {
                    var iElement = $(allInputs[i]);

                    if(iElement.attr('name') == inputElement.attr('name')) {
                        $(allInputs[i+1]).focus();
                        break;
                    }
                }
            }
        } else {
            preventDefault = false;
        }

        if(preventDefault) {
            e.preventDefault();
            return false;
        } else {
            return true;
        }
    }
});

The script tabs when pressing enter until the last input is reached. You could make this a bit more sophisticated to integrate with the tab index from Mendix. And to let it find the "submit" button when pressing enter on the last input.

BTW the script doesn't distinguish between desktop/tablet/phone.

answered