src/hbcore/inputfw/hbinputfocusobject.cpp
changeset 7 923ff622b8b9
parent 6 c3690ec91ef8
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
6:c3690ec91ef8 7:923ff622b8b9
    37 #include "hbinputeditorinterface.h"
    37 #include "hbinputeditorinterface.h"
    38 #include "hbinputvkbhost.h"
    38 #include "hbinputvkbhost.h"
    39 #include "hbinputstandardfilters.h"
    39 #include "hbinputstandardfilters.h"
    40 #include "hbinpututils.h"
    40 #include "hbinpututils.h"
    41 #include "hbnamespace_p.h"
    41 #include "hbnamespace_p.h"
    42 
    42 #include "hbevent.h"
    43 /*!
    43 /*!
    44 @alpha
    44 @alpha
    45 @hbcore
    45 @hbcore
    46 \class HbInputFocusObject
    46 \class HbInputFocusObject
    47 \brief A helper class for accessing editor widget in abstract way.
    47 \brief A helper class for accessing editor widget in abstract way.
    94 /// @endcond
    94 /// @endcond
    95 
    95 
    96 HbInputFocusObject::HbInputFocusObject(QObject *focusedObject)
    96 HbInputFocusObject::HbInputFocusObject(QObject *focusedObject)
    97     : d_ptr(new HbInputFocusObjectPrivate(focusedObject))
    97     : d_ptr(new HbInputFocusObjectPrivate(focusedObject))
    98 {
    98 {
       
    99     if (focusedObject) {
       
   100         HbEvent *event = new HbEvent(HbEvent::InputMethodFocusIn);
       
   101         QCoreApplication::sendEvent(focusedObject, event);
       
   102         delete event;
       
   103     }
    99 }
   104 }
   100 
   105 
   101 
   106 
   102 HbInputFocusObject::~HbInputFocusObject()
   107 HbInputFocusObject::~HbInputFocusObject()
   103 {
   108 {
       
   109     Q_D(HbInputFocusObject);
       
   110 
       
   111     if (d->mFocusedObject) {
       
   112         HbEvent *event = new HbEvent(HbEvent::InputMethodFocusOut);
       
   113         QCoreApplication::sendEvent(d->mFocusedObject, event);
       
   114         delete event;
       
   115     }
       
   116 
   104     delete d_ptr;
   117     delete d_ptr;
   105 }
   118 }
   106 
   119 
   107 /*!
   120 /*!
   108 Creates an input method event where given string is a pre-edit string and sends
   121 Creates an input method event where given string is a pre-edit string and sends
   377 Returns cursor micro focus by sending Qt::ImMicroFocus to focused editor.
   390 Returns cursor micro focus by sending Qt::ImMicroFocus to focused editor.
   378 In case of QGraphicsObject, the returned rectangle is in scene coordinates.
   391 In case of QGraphicsObject, the returned rectangle is in scene coordinates.
   379 */
   392 */
   380 QRectF HbInputFocusObject::microFocus() const
   393 QRectF HbInputFocusObject::microFocus() const
   381 {
   394 {
   382     return inputMethodQuery(Qt::ImMicroFocus).toRectF();
   395     Q_D(const HbInputFocusObject);
       
   396 
       
   397     QRectF rect = inputMethodQuery(Qt::ImMicroFocus).toRectF();
       
   398     QGraphicsObject *editorWidget = qobject_cast<QGraphicsObject*>(d->mFocusedObject);
       
   399     if (editorWidget) {
       
   400         rect = editorWidget->mapRectToScene(rect);
       
   401     }
       
   402 
       
   403     return rect;
   383 }
   404 }
   384 
   405 
   385 /*!
   406 /*!
   386 Returns active pre-edit string. Note that this method works only if the pre-edit
   407 Returns active pre-edit string. Note that this method works only if the pre-edit
   387 string was set by using this class.
   408 string was set by using this class.