Is there a way to prevent mobile keyboard from displaying for a gwtchosen widget?

23 views
Skip to first unread message

Rogelio Flores

unread,
Feb 19, 2016, 6:00:30 PM2/19/16
to gwtquery
I'm using gwtchosen 3.1-SNAPSHOT with GWT 2.7 and when my web interface runs in mobile phones, I've noticed the keyboard will appear every time the gwtchosen listbox is tapped. I guess it's useful if a user will always start selecting by searching, but I'm wondering if that's an option we can disable.




Rogelio Flores

unread,
Mar 23, 2016, 2:34:20 PM3/23/16
to gwtquery
In case somebody wants to do this, even if in a hackish way, this is what I do:

First, I already used a custom Resource to override the styles, and in the css, I set "display: none" to the input tag (the search textbox).

Then (using gquery) I add Showing/Hiding DropDownHandlers:

chosenListBox.addShowingDropDownHandler(new ShowingDropDownHandler()
        {
            @Override
            public void onShowingDropDown()
            {
                Timer timer = new Timer()
                {
                    @Override
                    public void run()
                    {
                        $(".chzn-search > input").css("display", "inline-block");
                    }
                };
                timer.schedule(400);
                         }
        };

chosenListBox.addHidingDropDownHandler(new HidingDropDownHandler()
        {
            @Override
            public void onHidingDropdown()
            {
                $(".chzn-search > input").css("display", "none");
            }
        };

So the textbox is not visible until ~half a second after the popup is displayed which is almost unnoticeable to a user, therefore a phone doesn't display the keyboard. You can still tap on the textbox and the keyboard appears. This code only runs on a phone form factor (I use mgwt to ensure that). You could also make the textbox "readonly" and then remove that attribute since according to reports online, the keyboard won't appear for read-only input text tags.

Reply all
Reply to author
Forward
0 new messages