[webkit-qt] QtWebkit & Virtual Keyboard
İsmail Dönmez
ismail at namtrac.org
Tue Apr 27 08:33:11 PDT 2010
This is OK for a hack but there needs to be public methods similar to your
selectedInput() and selectedNode() functions.
Regards,
ismail
On Tue, Apr 27, 2010 at 4:30 PM, Andrew Webster <apwebster at gmail.com> wrote:
> I did something similar for text inputs. I hacked a class called
> QWebPageEx that extends QWebPage into webkit that is able to determine
> if a text field is selected and get and set the text in it. In my
> user app, I extended QWebPageEx and then every time there is a
> MouseButtonRelease I check if a text field is selected and then open a
> soft keyboard.
>
> It's not the cleanest method and it breaks every time there's a major
> update to webkit, but it does work. You may be able to do something
> similar for list/combo boxes.
>
> Here is the header:
> #include "qwebpage.h"
>
> namespace WebCore
> {
> class Node;
> class HTMLInputElement;
> }
>
> class QWEBKIT_EXPORT QWebPageEx : public QWebPage
> {
> public:
> QWebPageEx(QObject *parent = 0);
> ~QWebPageEx();
>
> bool isTextField() const;
> bool isPasswordField() const;
>
> QString text() const;
> void setText(const QString& text);
> QString getAttribute(const QString& attrName);
>
> private:
> WebCore::Node* selectedNode() const;
> WebCore::HTMLInputElement* selectedInput() const;
> };
>
> And the source:
> #include "qwebpageex.h"
> #include "config.h"
> #include "qwebpage_p.h"
>
> #include "Frame.h"
> #include "Page.h"
> #include "FocusController.h"
> #include "HTMLInputElement.h"
> #include "HTMLNames.h"
> #include "ClientRect.h"
> #include "JSDOMWindow.h"
>
> QWebPageEx::QWebPageEx(QObject *parent) :
> QWebPage(parent)
> {
> }
>
> QWebPageEx::~QWebPageEx()
> {
> }
>
> bool QWebPageEx::isTextField() const
> {
> const WebCore::HTMLInputElement *input = selectedInput();
>
> if (input)
> {
> return input->isTextField();
> }
>
> return false;
> }
>
> bool QWebPageEx::isPasswordField() const
> {
> const WebCore::HTMLInputElement *input = selectedInput();
>
> if (input)
> {
> return input->isPasswordField();
> }
>
> return false;
> }
>
> QString QWebPageEx::text() const
> {
> const WebCore::HTMLInputElement *input = selectedInput();
>
> if (input)
> {
> return input->value();
> }
>
> return QString();
> }
>
> void QWebPageEx::setText(const QString& text)
> {
> WebCore::HTMLInputElement *input = selectedInput();
>
> if (input)
> {
> input->setValue(text);
> input->dispatchFormControlChangeEvent();
> }
> }
>
> QString QWebPageEx::getAttribute(const QString& attrName)
> {
> WebCore::Node *node = selectedNode();
>
> if (node && node->hasAttributes())
> {
> WebCore::NamedNodeMap *attrs = node->attributes();
>
> if (attrs)
> {
> WTF::PassRefPtr<WebCore::Node> nd = attrs->getNamedItem(attrName);
>
> if (nd.get())
> {
> return nd->nodeValue();
> }
> }
> }
>
> return QString();
> }
>
> WebCore::Node* QWebPageEx::selectedNode() const
> {
> WebCore::Frame *frame =
> handle()->page->focusController()->focusedOrMainFrame();
> if (frame)
> {
> WebCore::Document *document = frame->document();
>
> if (document)
> {
> WebCore::Node *node = document->focusedNode();
>
> if (node)
> {
> return node;
> }
> }
> }
>
> return NULL;
> }
>
> WebCore::HTMLInputElement* QWebPageEx::selectedInput() const
> {
> WebCore::Node *node = selectedNode();
>
> if (node && node->hasTagName(WebCore::HTMLNames::inputTag))
> {
> return static_cast<WebCore::HTMLInputElement*>(node);
> }
>
> return NULL;
> }
>
> Andrew
>
> On Tue, Apr 27, 2010 at 3:07 AM, Ivan De Marino
> <ivan.de.marino at gmail.com> wrote:
> > Input methods in Qt are defined by-platform, and that should not change
> if
> > you are in a QWebView.
> > If you want to modify what do you get in terms of Keyboards, Combo-box
> and
> > so forth, you might want to take a look to the actual source code of
> > QtWebKit and see where you can "plug yourself" in. It's not going to be
> an
> > easy task, I think.
> > It might be that you are raising an interesting point: allowing
> developers
> > to implement/extend the input methods for QWebKit, so that personalized
> > Input Methods can be easily added. that's an interesting idea.
> > Good luck.
> >
> > On 27 April 2010 07:39, sunny shah <sunny.cpp at gmail.com> wrote:
> >>
> >> Hi ,
> >> But I want to make it for Qt for embedded linux ( My windowing server
> is
> >> QWS ( Qt Windowing System) ), I want to mentioned functionality ( Want
> to
> >> make mobile browser similar to iPhone | Android ). Isn't it possible
> that
> >> textbox OR listbox OR combobox which QtWebkit uses will be derived by
> me ?
> >> Or is there any other way? I am ready to do hacking in code, Just help
> me
> >> for quick start.
> >> Many Thanks,
> >> Sunny.
> >> On Tue, Apr 27, 2010 at 1:41 AM, Kenneth Christiansen
> >> <kenneth.christiansen at openbossa.org> wrote:
> >>>
> >>> We would all like that :-) but it is a lot of work to get done right.
> >>>
> >>> With QtWebKit 2.0 which will soon be released, and if your embedded
> >>> linux is based on Maemo5, you will get a dialog for selection (what
> >>> you call combobox/listbox), event for the multiple selection case. On
> >>> other platforms you are out of luck. Virtual keyboard will also work
> >>> on that platform.
> >>>
> >>> Kenneth
> >>>
> >>> On Mon, Apr 26, 2010 at 2:59 PM, sunny shah <sunny.cpp at gmail.com>
> wrote:
> >>> > Hi,
> >>> >
> >>> > I am making mobile browser for Qt for embedded linux. I want to
> have
> >>> > virtual keyboard, separate window for listbox and combo box and
> custom
> >>> > message box styles in QtWebkit. Please help me with this.
> >>> >
> >>> > Regards,
> >>> > Sunny.
> >>> > _______________________________________________
> >>> > webkit-qt mailing list
> >>> > webkit-qt at lists.webkit.org
> >>> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt
> >>> >
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Kenneth Rohde Christiansen
> >>> Technical Lead / Senior Software Engineer
> >>> Qt Labs Americas, Nokia Technology Institute, INdT
> >>> Phone +55 81 8895 6002 / E-mail kenneth.christiansen at openbossa.org
> >>
> >>
> >> _______________________________________________
> >> webkit-qt mailing list
> >> webkit-qt at lists.webkit.org
> >> http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt
> >>
> >
> >
> >
> > --
> > Ivan De Marino | Software Engineer | France Telecom R&D UK - Orange Labs
> > w. +44 20 8849 5806 | m. +44 7515 955 861 | m. +44 7974 156 216
> > ivan[dot]demarino[at]orange-ftgroup.com |
> > ivan[dot]de[dot]marino[at]gmail[dot]com
> > www.detronizator.org | www.linkedin.com/in/ivandemarino
> >
> > _______________________________________________
> > webkit-qt mailing list
> > webkit-qt at lists.webkit.org
> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt
> >
> >
> _______________________________________________
> webkit-qt mailing list
> webkit-qt at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20100427/2f8e025b/attachment.html>
More information about the webkit-qt
mailing list