This commit is contained in:
tague%netscape.com 1999-06-11 20:32:09 +00:00
Родитель 57b3c3e5d8
Коммит e885d271de
4 изменённых файлов: 61 добавлений и 39 удалений

Просмотреть файл

@ -129,19 +129,19 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
if (PR_FALSE==keyProcessed)
{
switch(keyCode) {
case nsIDOMUIEvent::VK_BACK:
mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
break;
// case nsIDOMUIEvent::VK_BACK:
// mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
// break;
case nsIDOMUIEvent::VK_DELETE:
mEditor->DeleteSelection(nsIEditor::eDeleteRight);
break;
case nsIDOMUIEvent::VK_RETURN:
// case nsIDOMUIEvent::VK_RETURN:
//case nsIDOMUIEvent::VK_ENTER: // why does this not exist?
// Need to implement creation of either <P> or <BR> nodes.
mEditor->InsertBreak();
break;
// mEditor->InsertBreak();
// break;
case nsIDOMUIEvent::VK_LEFT:
case nsIDOMUIEvent::VK_RIGHT:
@ -271,6 +271,7 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
{
nsAutoString key;
PRUint32 character;
PRUint32 keyCode;
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aKeyEvent);
@ -278,17 +279,27 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
//non-key event passed to keydown. bad things.
return NS_OK;
}
//
// look at the keyCode if it is return or backspace, process it
// we handle these two special characters here because it makes windows integration
// eaiser
//
if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode)))
{
if (nsIDOMUIEvent::VK_BACK==keyCode) {
mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
return NS_OK;
}
if (nsIDOMUIEvent::VK_RETURN==keyCode) {
mEditor->InsertBreak();
return NS_OK;
}
}
if (NS_SUCCEEDED(uiEvent->GetCharCode(&character)))
{
//
// this is a temporary hack to get around the re-firing of key_downs as key_presses
// in nsEventStateManager
//
if (character<0x20) { return NS_OK; }
key += character;
if (0!=character)
return mEditor->InsertText(key);
return mEditor->InsertText(key);
}
return NS_ERROR_BASE;

Просмотреть файл

@ -129,19 +129,19 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
if (PR_FALSE==keyProcessed)
{
switch(keyCode) {
case nsIDOMUIEvent::VK_BACK:
mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
break;
// case nsIDOMUIEvent::VK_BACK:
// mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
// break;
case nsIDOMUIEvent::VK_DELETE:
mEditor->DeleteSelection(nsIEditor::eDeleteRight);
break;
case nsIDOMUIEvent::VK_RETURN:
// case nsIDOMUIEvent::VK_RETURN:
//case nsIDOMUIEvent::VK_ENTER: // why does this not exist?
// Need to implement creation of either <P> or <BR> nodes.
mEditor->InsertBreak();
break;
// mEditor->InsertBreak();
// break;
case nsIDOMUIEvent::VK_LEFT:
case nsIDOMUIEvent::VK_RIGHT:
@ -271,6 +271,7 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
{
nsAutoString key;
PRUint32 character;
PRUint32 keyCode;
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aKeyEvent);
@ -278,17 +279,27 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
//non-key event passed to keydown. bad things.
return NS_OK;
}
//
// look at the keyCode if it is return or backspace, process it
// we handle these two special characters here because it makes windows integration
// eaiser
//
if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode)))
{
if (nsIDOMUIEvent::VK_BACK==keyCode) {
mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
return NS_OK;
}
if (nsIDOMUIEvent::VK_RETURN==keyCode) {
mEditor->InsertBreak();
return NS_OK;
}
}
if (NS_SUCCEEDED(uiEvent->GetCharCode(&character)))
{
//
// this is a temporary hack to get around the re-firing of key_downs as key_presses
// in nsEventStateManager
//
if (character<0x20) { return NS_OK; }
key += character;
if (0!=character)
return mEditor->InsertText(key);
return mEditor->InsertText(key);
}
return NS_ERROR_BASE;

Просмотреть файл

@ -2102,18 +2102,18 @@ BOOL nsWindow::OnKeyUp( UINT aVirtualKeyCode, UINT aScanCode)
//
//-------------------------------------------------------------------------
#ifdef tague_keyboard_patch
BOOL nsWindow::OnChar( UINT aVirtualKeyCode, bool isMultiByte )
BOOL nsWindow::OnChar( UINT mbcsCharCode, UINT virtualKeyCode, bool isMultiByte )
{
wchar_t uniChar;
char charToConvert[2];
size_t length;
if (isMultiByte) {
charToConvert[0]=HIBYTE(aVirtualKeyCode);
charToConvert[1] = LOBYTE(aVirtualKeyCode);
charToConvert[0]=HIBYTE(mbcsCharCode);
charToConvert[1] = LOBYTE(mbcsCharCode);
length=2;
} else {
charToConvert[0] = LOBYTE(aVirtualKeyCode);
charToConvert[0] = LOBYTE(mbcsCharCode);
length=1;
}
// if we get a '\n', ignore it because we already processed it in OnKeyDown.
@ -2125,7 +2125,7 @@ BOOL nsWindow::OnChar( UINT aVirtualKeyCode, bool isMultiByte )
::MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,charToConvert,length,
&uniChar,sizeof(uniChar));
DispatchKeyEvent(NS_KEY_PRESS, uniChar, uniChar);
DispatchKeyEvent(NS_KEY_PRESS, uniChar, virtualKeyCode);
return FALSE;
}
@ -2272,11 +2272,11 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
UINT char_result;
//
// check first for backspace or return, these are currently being handled on
// the WM_KEYDOWN
// check first for backspace or return, handle them specially
//
if (ch==0x0d || ch==0x08) {
result = PR_TRUE;
mHaveDBCSLeadByte = PR_FALSE;
result = OnChar(ch,ch==0x0d ? VK_RETURN : VK_BACK,true);
break;
}
@ -2299,10 +2299,10 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
char_result = (mDBCSLeadByte << 8) | ch;
mHaveDBCSLeadByte = FALSE;
mDBCSLeadByte = 0;
result = OnChar(char_result,true);
result = OnChar(char_result,0,true);
} else {
char_result = ch;
result = OnChar(char_result,false);
result = OnChar(char_result,0,false);
}
break;

Просмотреть файл

@ -175,7 +175,7 @@ protected:
virtual PRBool OnResize(nsRect &aWindowRect);
#ifdef tague_keyboard_patch
BOOL OnChar(UINT aVirtualKeyCode, bool isMultibyte);
BOOL OnChar(UINT mbcsCharCode, UINT virtualKeyCode, bool isMultibyte);
#else
BOOL OnChar(UINT aVirtualKeyCode);
#endif