moved the spacebar handling code from js to c++ so that spacebar works for embedding apps. fixed bug 71760, r=brendan, sr=hyatt, a=blizzard.

git-svn-id: svn://10.0.0.236/trunk@93356 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
arik%netscape.com 2001-04-28 02:32:14 +00:00
parent b3b8e794ed
commit 2e12a447a4
3 changed files with 17 additions and 38 deletions

View File

@ -30,43 +30,7 @@ Can't yet put script tags in XBL (hyatt has the bug)
-->
</handler>
<handler event="keypress" key=" ">
<![CDATA[
var v = document.commandDispatcher.focusedElement;
if (v) {
switch (v.localName) {
case 'TEXTAREA':
return true;
case 'INPUT':
switch (v.getAttribute('type').toLowerCase()) {
case 'button':
case 'image':
case 'submit':
case 'reset':
case 'checkbox':
case 'radio':
case 'file':
return true;
}
break;
case 'BUTTON':
switch (v.getAttribute('type').toLowerCase()) {
case 'submit':
case 'button':
case 'reset':
return true;
}
break;
}
}
var controller =
document.commandDispatcher.getControllerForCommand('cmd_scrollPageDown');
controller.doCommand('cmd_scrollPageDown');
return true;
]]>
</handler>
<handler event="keypress" key=" " command="cmd_scrollPageDown" />
<handler event="keypress" keycode="VK_PAGE_UP" command="cmd_scrollPageUp" />
<handler event="keypress" keycode="VK_PAGE_DOWN" command="cmd_scrollPageDown" />

View File

@ -194,7 +194,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver, nsIDOMEven
nsCOMPtr<nsIAtom> tag;
mHandlerElement->GetTag(*getter_AddRefs(tag));
PRBool isXULKey = (tag.get() == nsXULAtoms::key);
PRBool isReceiverCommandElement = PR_FALSE;
nsCOMPtr<nsIContent> content(do_QueryInterface(aReceiver));
if (isXULKey && content && content.get() != mHandlerElement)
@ -862,6 +862,20 @@ PRInt32 nsXBLPrototypeHandler::KeyToMask(PRInt32 key)
return cControl; // for warning avoidance
}
void
nsXBLPrototypeHandler::GetEventType(nsAWritableString &type)
{
mHandlerElement->GetAttribute(kNameSpaceID_None, kTypeAtom, type);
if (type.IsEmpty()) {
// If we're a XUL key element, let's assume that we're "keypress".
nsCOMPtr<nsIAtom> tag;
mHandlerElement->GetTag(*getter_AddRefs(tag));
if (tag.get() == kKeyAtom)
type = NS_LITERAL_STRING("keypress");
}
}
void
nsXBLPrototypeHandler::ConstructMask()
{

View File

@ -84,6 +84,7 @@ protected:
inline PRInt32 GetMatchingKeyCode(const nsString& aKeyName);
void ConstructMask();
void GetEventType(nsAWritableString& type);
PRBool ModifiersMatchMask(nsIDOMUIEvent* aEvent);
inline PRBool KeyEventMatched(nsIDOMKeyEvent* aKeyEvent);