barmalei / zebkit

JavaScript library that follows easy OOP concept, provides HTML5 Canvas based Rich UI and includes Java to JavaScript converter tool
Apache License 2.0
931 stars 177 forks source link

HtmlTextInput cannot show SoftKeyboard in safari on iOS9.1(branch zebkit-next-generation) #81

Open jfojfo opened 8 years ago

jfojfo commented 8 years ago

if comment out e.preventDefault() or change it to e.stopPropagation() in PointerEventUnifier, keyborad will show normally.

element.addEventListener("touchstart", function(e){
   ...
   //e.preventDefault();
   e.stopPropagation();
});
element.addEventListener("touchend", function(e){
   ...
   //e.preventDefault();
   e.stopPropagation();
});
element.addEventListener("touchmove", function(e){
   ...
   //e.preventDefault();
   e.stopPropagation();
});

testing code follows:

    eval(zebra.Import("ui", "layout"));

    var root = new zCanvas(400, 400).root;
    root.setPadding(8);
    root.setBorder("plain");
    root.setBackground("#EEEEEE");
    root.setLayout(new BorderLayout(4,4));
    root.add(LEFT, new HtmlTextArea("HTML text area"));
    root.add(TOP, new HtmlTextField("HTML input field"));
    root.add(CENTER, new TextArea("Zebra text area"));
    root.add(BOTTOM, new Button("Test"));
jfojfo commented 8 years ago

only deal with input and textarea

// in PointerEventUnifier:
                element.addEventListener("touchstart", function(e) {
                    ...

                    var tagName = e.target.tagName.toLowerCase();
                    if (tagName !== 'input' && tagName !== 'textarea' || e.target.hasAttribute('readonly')) {
                        e.preventDefault();
                    }

                }, false);

                element.addEventListener("touchend", function(e) {
                    ...

                    var tagName = e.target.tagName.toLowerCase();
                    if (tagName !== 'input' && tagName !== 'textarea' || e.target.hasAttribute('readonly')) {
                        e.preventDefault();
                    }

                }, false);
jfojfo commented 8 years ago

fixed many problems in my branch, see https://github.com/jfojfo/zebra