Commit a440d629 authored by darin's avatar darin
Browse files

Reviewed by Ken.

	- fixed 3126042 -- Failure to send onkeypress event on key down causes forms to submit incorrectly

        * kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::keyEvent): Fixed the code to send the second event with repeat
	set equal to true. Before it was constructing the event but never sending it because result was true.
	Also fixed a problem where it was considering sending a second mouse up event. What we're doing here
	is a bit of a hack and probably should be fixed -- it seems that the behavior in dispatchKeyEvent where
	it sends only a down and not a press for the a non-autorepeat event is a KHTML bug that we should fix
	instead of work around eventually.

        - fix to something that made this harder to debug

        * khtml/xml/dom2_eventsimpl.cpp: (KeyEventImpl::KeyEventImpl): Logging the type was showing the wrong
	type, and I narrowed it down to this code here. Changing m_id after the fact doesn't change the type
	string, so you need to compute the correct ID and pass it to the constructor.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d0bcf452
2002-12-12 Darin Adler <darin@apple.com>
Reviewed by Ken.
- fixed 3126042 -- Failure to send onkeypress event on key down causes forms to submit incorrectly
* kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::keyEvent): Fixed the code to send the second event with repeat
set equal to true. Before it was constructing the event but never sending it because result was true.
Also fixed a problem where it was considering sending a second mouse up event. What we're doing here
is a bit of a hack and probably should be fixed -- it seems that the behavior in dispatchKeyEvent where
it sends only a down and not a press for the a non-autorepeat event is a KHTML bug that we should fix
instead of work around eventually.
- fix to something that made this harder to debug
* khtml/xml/dom2_eventsimpl.cpp: (KeyEventImpl::KeyEventImpl): Logging the type was showing the wrong
type, and I narrowed it down to this code here. Changing m_id after the fact doesn't change the type
string, so you need to compute the correct ID and pass it to the constructor.
2002-12-12 Darin Adler <darin@apple.com>
Reviewed by Ken.
......
2002-12-12 Darin Adler <darin@apple.com>
Reviewed by Ken.
- fixed 3126042 -- Failure to send onkeypress event on key down causes forms to submit incorrectly
* kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::keyEvent): Fixed the code to send the second event with repeat
set equal to true. Before it was constructing the event but never sending it because result was true.
Also fixed a problem where it was considering sending a second mouse up event. What we're doing here
is a bit of a hack and probably should be fixed -- it seems that the behavior in dispatchKeyEvent where
it sends only a down and not a press for the a non-autorepeat event is a KHTML bug that we should fix
instead of work around eventually.
- fix to something that made this harder to debug
* khtml/xml/dom2_eventsimpl.cpp: (KeyEventImpl::KeyEventImpl): Logging the type was showing the wrong
type, and I narrowed it down to this code here. Changing m_id after the fact doesn't change the type
string, so you need to compute the correct ID and pass it to the constructor.
2002-12-12 Darin Adler <darin@apple.com>
Reviewed by Ken.
......
......@@ -506,7 +506,8 @@ KeyEventImpl::KeyEventImpl()
}
KeyEventImpl::KeyEventImpl(QKeyEvent *key, AbstractViewImpl *view)
: UIEventImpl(KHTML_KEYDOWN_EVENT,true,true,view,0)
: UIEventImpl(key->type() == QEvent::KeyRelease ? KHTML_KEYUP_EVENT : key->isAutoRepeat() ? KHTML_KEYPRESS_EVENT : KHTML_KEYDOWN_EVENT,
true,true,view,0)
{
qKeyEvent = new QKeyEvent(key->type(), key->key(), key->ascii(), key->state(), key->text(), key->isAutoRepeat(), key->count() );
// Events are supposed to be accepted by default in Qt!
......@@ -514,13 +515,6 @@ KeyEventImpl::KeyEventImpl(QKeyEvent *key, AbstractViewImpl *view)
// (and e.g. space would make it scroll down)
//qKeyEvent->ignore();
if (key->type() == QEvent::KeyRelease)
m_id = KHTML_KEYUP_EVENT;
else if (key->isAutoRepeat())
m_id = KHTML_KEYPRESS_EVENT;
else if (key->type() == QEvent::KeyPress)
m_id = KHTML_KEYDOWN_EVENT;
m_detail = key->count();
m_numPad = false;
......
......@@ -678,19 +678,18 @@ bool KWQKHTMLPart::keyEvent(NSEvent *event)
stateForCurrentEvent(),
QString::fromNSString([event characters]),
[event isARepeat]);
bool result = node->dispatchKeyEvent(&qEvent);
// We want to send both a down and a press for the initial key event
if (![event isARepeat]) {
QKeyEvent qEvent([event type] == NSKeyDown ? QEvent::KeyPress : QEvent::KeyRelease,
// We want to send both a down and a press for the initial key event.
// This is a temporary hack; we need to do this a better way.
if ([event type] == NSKeyDown && ![event isARepeat]) {
QKeyEvent qEvent(QEvent::KeyPress,
[event keyCode],
ascii,
stateForCurrentEvent(),
QString::fromNSString([event characters]),
true);
result = result && node->dispatchKeyEvent(&qEvent);
node->dispatchKeyEvent(&qEvent);
}
_currentEvent = oldCurrentEvent;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment