[webkit-dev] is there any method to get current focus widget in webkit?

RyanYee/叶晔 godyee at gmail.com
Wed Nov 25 00:50:14 PST 2009


I have find way to do it,my code

bool QWebPage::canInput(QRect &pos)
{
    bool ret=false;
#if 0
        Frame *frame = d->page->focusController()->focusedFrame();
        qDebug()<<"ryan can input1:"<<(frame?1:0);
#endif   WebCore::Frame *frame1 =
d->page->focusController()->focusedOrMainFrame();
    Node * cur=frame1->document()->focusedNode();
    if(cur){
        qDebug("node:%s:%d",cur->nodeName().latin1().data(),cur->nodeType());
        pos=QRect(cur->getRect());
        qDebug("node :%d,%d,%d,%d",pos.x(),pos.y(),pos.width(),pos.height());
    }
    else {
        pos=QRect(0,0,0,0);
        qDebug("node null");
    }
    WebCore::Editor *editor = frame1->editor();
    ret=(editor->canEdit()?true:false);
    qDebug()<<"ryan can input2:"<<ret;
    return ret;
}

2009/11/20 RyanYee/叶晔 <godyee at gmail.com>:
> I am working on inputmethod base on our webkit/qtopia.
> I want apply this funtion,make inputmethod window can follow cursor
> position.so I must
> get current focused widget ,so I can tell it can input or not ,even
> it's position in window.
> but in QT ,I can only get QWebView.
> any suggestion can help me about this ,thanks
>
> --
> RyanYee
>



-- 
RyanYee


More information about the webkit-dev mailing list