don't allow other modifiers when cut/copy/pasting (bug #15693); this missed the keyEvent branch. r=kin@netscape.com
git-svn-id: svn://10.0.0.236/trunk@50828 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
a41c4bbacd
commit
a7ee842442
@ -252,6 +252,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
aProcessed=PR_FALSE;
|
||||
PRUint32 charCode;
|
||||
PRBool ctrlKey;
|
||||
PRBool isAltKey, isMetaKey, isShiftKey;
|
||||
|
||||
nsCOMPtr<nsIDOMUIEvent>uiEvent;
|
||||
uiEvent = do_QueryInterface(aKeyEvent);
|
||||
@ -261,6 +262,9 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(uiEvent->GetCharCode(&charCode)) &&
|
||||
NS_SUCCEEDED(uiEvent->GetCtrlKey(&isAltKey)) &&
|
||||
NS_SUCCEEDED(uiEvent->GetCtrlKey(&isMetaKey)) &&
|
||||
NS_SUCCEEDED(uiEvent->GetCtrlKey(&isShiftKey)) &&
|
||||
NS_SUCCEEDED(uiEvent->GetCtrlKey(&ctrlKey)) )
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
@ -268,10 +272,10 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
// metaKey query is only way to query for command key on Mac
|
||||
// if that's pressed, we'll set the ctrlKey boolean
|
||||
// (even though the control key might also be pressed)
|
||||
PRBool isMetaKey;
|
||||
if (NS_SUCCEEDED(uiEvent->GetMetaKey(&isMetaKey)) && PR_TRUE==isMetaKey) {
|
||||
if (PR_TRUE==isMetaKey) {
|
||||
ctrlKey = !ctrlKey; /* if controlKey is pressed, we shouldn't execute code below */
|
||||
/* if it's not set and cmdKey is, then we should proceed to code below */
|
||||
isMetaKey = PR_FALSE; /* reset so there aren't extra modifiers to prevent binding from working */
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -284,7 +288,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
{
|
||||
// XXX: hard-coded select all
|
||||
case (PRUint32)('a'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->SelectAll();
|
||||
@ -293,7 +297,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded cut
|
||||
case (PRUint32)('x'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->Cut();
|
||||
@ -302,7 +306,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded copy
|
||||
case (PRUint32)('c'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->Copy();
|
||||
@ -311,7 +315,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded paste
|
||||
case (PRUint32)('v'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
printf("control-v\n");
|
||||
if (mEditor)
|
||||
@ -321,7 +325,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded undo
|
||||
case (PRUint32)('z'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->Undo(1);
|
||||
@ -330,7 +334,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded redo
|
||||
case (PRUint32)('y'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->Redo(1);
|
||||
|
||||
@ -252,6 +252,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
aProcessed=PR_FALSE;
|
||||
PRUint32 charCode;
|
||||
PRBool ctrlKey;
|
||||
PRBool isAltKey, isMetaKey, isShiftKey;
|
||||
|
||||
nsCOMPtr<nsIDOMUIEvent>uiEvent;
|
||||
uiEvent = do_QueryInterface(aKeyEvent);
|
||||
@ -261,6 +262,9 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(uiEvent->GetCharCode(&charCode)) &&
|
||||
NS_SUCCEEDED(uiEvent->GetCtrlKey(&isAltKey)) &&
|
||||
NS_SUCCEEDED(uiEvent->GetCtrlKey(&isMetaKey)) &&
|
||||
NS_SUCCEEDED(uiEvent->GetCtrlKey(&isShiftKey)) &&
|
||||
NS_SUCCEEDED(uiEvent->GetCtrlKey(&ctrlKey)) )
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
@ -268,10 +272,10 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
// metaKey query is only way to query for command key on Mac
|
||||
// if that's pressed, we'll set the ctrlKey boolean
|
||||
// (even though the control key might also be pressed)
|
||||
PRBool isMetaKey;
|
||||
if (NS_SUCCEEDED(uiEvent->GetMetaKey(&isMetaKey)) && PR_TRUE==isMetaKey) {
|
||||
if (PR_TRUE==isMetaKey) {
|
||||
ctrlKey = !ctrlKey; /* if controlKey is pressed, we shouldn't execute code below */
|
||||
/* if it's not set and cmdKey is, then we should proceed to code below */
|
||||
isMetaKey = PR_FALSE; /* reset so there aren't extra modifiers to prevent binding from working */
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -284,7 +288,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
{
|
||||
// XXX: hard-coded select all
|
||||
case (PRUint32)('a'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->SelectAll();
|
||||
@ -293,7 +297,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded cut
|
||||
case (PRUint32)('x'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->Cut();
|
||||
@ -302,7 +306,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded copy
|
||||
case (PRUint32)('c'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->Copy();
|
||||
@ -311,7 +315,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded paste
|
||||
case (PRUint32)('v'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
printf("control-v\n");
|
||||
if (mEditor)
|
||||
@ -321,7 +325,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded undo
|
||||
case (PRUint32)('z'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->Undo(1);
|
||||
@ -330,7 +334,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||
|
||||
// XXX: hard-coded redo
|
||||
case (PRUint32)('y'):
|
||||
if (PR_TRUE==ctrlKey)
|
||||
if (PR_TRUE==ctrlKey && PR_FALSE==isShiftKey && PR_FALSE==isAltKey && PR_FALSE==isMetaKey)
|
||||
{
|
||||
if (mEditor)
|
||||
mEditor->Redo(1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user