[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/unity/WebKit/WebCore
From: Nikolas Zimmermann <wildfox () kde ! org>
Date: 2006-07-31 0:37:41
Message-ID: 1154306261.503911.664.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 568074 by wildfox:
First stab at keyboard events. The google input field now works properly,
including selection & deletion of text. Now we only need buttons to get
a working google search :-) Please review, and let me know what you think.
M +1 -0 CMakeLists.txt
M +7 -0 platform/PlatformKeyboardEvent.h
M +54 -1 platform/qt/CanvasQt.cpp
M +3 -0 platform/qt/CanvasQt.h
A platform/qt/KeyboardCodes.h [License: UNKNOWN]
A platform/qt/PlatformKeyboardEventQt.cpp [License: UNKNOWN]
--- branches/work/unity/WebKit/WebCore/CMakeLists.txt #568073:568074
@@ -797,6 +797,7 @@
platform/qt/TextEditQt.cpp
platform/qt/CanvasQt.cpp
platform/qt/PlatformMouseEventQt.cpp
+ platform/qt/PlatformKeyboardEventQt.cpp
platform/image-decoders/bmp/BMPImageDecoder.cpp
platform/image-decoders/gif/GIFImageReader.cpp
platform/image-decoders/gif/GIFImageDecoder.cpp
--- branches/work/unity/WebKit/WebCore/platform/PlatformKeyboardEvent.h \
#568073:568074 @@ -44,6 +44,9 @@
typedef union _GdkEvent GdkEvent;
#endif
+#if PLATFORM(QT)
+class QKeyEvent;
+#endif
namespace WebCore {
@@ -73,6 +76,10 @@
PlatformKeyboardEvent(GdkEvent*);
#endif
+#if PLATFORM(QT)
+ PlatformKeyboardEvent(QKeyEvent*, bool isKeyUp);
+#endif
+
private:
String m_text;
String m_unmodifiedText;
--- branches/work/unity/WebKit/WebCore/platform/qt/CanvasQt.cpp #568073:568074
@@ -32,8 +32,12 @@
#include <config.h>
#include "FrameView.h"
#include "Frame.h"
+#include "TypingCommand.h"
+#include "KeyboardCodes.h"
#include "GraphicsContext.h"
+#include "SelectionController.h"
#include "PlatformMouseEvent.h"
+#include "PlatformKeyboardEvent.h"
#include <QDebug>
#include <QPainter>
@@ -46,6 +50,7 @@
: QWidget(parent), m_frameView(frameView)
{
setMouseTracking(true);
+ setFocusPolicy(Qt::StrongFocus);
}
void CanvasQt::paintEvent(QPaintEvent *ev)
@@ -92,6 +97,54 @@
void CanvasQt::keyPressEvent(QKeyEvent *ev)
{
-
+ handleKeyEvent(ev, false);
}
+
+void CanvasQt::keyReleaseEvent(QKeyEvent *ev)
+{
+ handleKeyEvent(ev, true);
+}
+
+void CanvasQt::handleKeyEvent(QKeyEvent *ev, bool isKeyUp)
+{
+ PlatformKeyboardEvent kevent(ev, isKeyUp);
+ bool handled = false;
+
+ FrameView *fv = static_cast<FrameView*>(m_frameView);
+ Frame *frame = (fv ? fv->frame() : 0);
+ if (!frame)
+ return;
+
+ if (!kevent.isKeyUp()) {
+ Node* start = frame->selection().start().node();
+ if (start && start->isContentEditable()) {
+ switch(kevent.WindowsKeyCode()) {
+ case VK_BACK:
+ TypingCommand::deleteKeyPressed(frame->document());
+ break;
+ case VK_DELETE:
+ TypingCommand::forwardDeleteKeyPressed(frame->document());
+ break;
+ case VK_LEFT:
+ frame->selection().modify(SelectionController::MOVE, \
SelectionController::LEFT, CharacterGranularity); + break;
+ case VK_RIGHT:
+ frame->selection().modify(SelectionController::MOVE, \
SelectionController::RIGHT, CharacterGranularity); + break;
+ case VK_UP:
+ frame->selection().modify(SelectionController::MOVE, \
SelectionController::BACKWARD, ParagraphGranularity); + break;
+ case VK_DOWN:
+ frame->selection().modify(SelectionController::MOVE, \
SelectionController::FORWARD, ParagraphGranularity); + break;
+ default:
+ TypingCommand::insertText(frame->document(), kevent.text(), \
false); +
+ }
+ handled = true;
+ }
+ qDebug() << "HANDLED: " << handled;
+ }
+}
+
// vim: ts=4 sw=4 et
--- branches/work/unity/WebKit/WebCore/platform/qt/CanvasQt.h #568073:568074
@@ -52,7 +52,10 @@
virtual void mousePressEvent(QMouseEvent *ev);
virtual void mouseReleaseEvent(QMouseEvent *ev);
virtual void keyPressEvent(QKeyEvent *ev);
+ virtual void keyReleaseEvent(QKeyEvent *ev);
private:
+ void handleKeyEvent(QKeyEvent *ev, bool isKeyUp);
+
WebCore::ScrollView *m_frameView;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic