Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#15 Prevent (Apply Changes) <F10> from setting focus to the menu

v1.9
closed
Patrick Wolf
None
5
2007-12-06
2007-12-06
Chris Neumueller
No

Hi Patrick!

We've already talked about it, if you add the following code to the GM script, <F10> just simulates the click to "Apply Changes" without setting the focus to the menu. The latter is the default behaviour, at least on FF, didn't test it with IE. Btw, if you search for "preventDefault" in jquery.js, it does several other things, too. As I'm a javascript newbie and you're a pro, I'll leave adding the perfect code to you ;-).

Hth and lots of greetings,
Chris

//==============================================================================
// Checks if the pressed key is assigned to a button or link and simulates a
// click event for that element if necessary.
//==============================================================================
ApexBuilderPlugin.checkAssignedKeys = function(pEvent)
{
var vKeyList = null;
// if it's one of our registered keys
if (ApexBuilderPlugin.sAssignedKeyList[pEvent.keyCode])
{
vKeyList = ApexBuilderPlugin.sAssignedKeyList[pEvent.keyCode];

// Does the key event match to one of our entries?
for (var i=0; i<vKeyList.length; i++)
{
if ((pEvent.ctrlKey ==vKeyList[i].oCtrlKey ) &&
(pEvent.shiftKey==vKeyList[i].oShiftKey) &&
(pEvent.altKey ==vKeyList[i].oAltKey ) &&
((pEvent.metaKey==undefined) ||
(pEvent.metaKey==vKeyList[i].oMetaKey))
)
{
// if it's a clickable element, fire the click event
// otherwise just set the focus to the element
if ((vKeyList[i].oElement.tagName=="INPUT" &&
vKeyList[i].oElement.type == "button") ||
(vKeyList[i].oElement.tagName=="A")
)
{
// fire click event
ApexBuilderPlugin.fireEventHandler(vKeyList[i].oElement, "click");
// highlight the field
ApexBuilderPlugin.highlightObject(vKeyList[i].oElement,
"#ffd700", 1000);
}
else
{
// highlighting when setting focus doesn't work, because afterwards
// the cursor indicator isn't visible, so just set the focus to the
// element
vKeyList[i].oElement.focus();
}

// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
if (pEvent.preventDefault)
pEvent.preventDefault(); // http://www.w3.org/TR/2001/WD-DOM-Level-3-Events-20010823/events.html
else
pEvent.returnValue = false; // IE version
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
}
}
}; // checkAssignedKeys

Discussion

  • Patrick Wolf
    Patrick Wolf
    2007-12-06

    Logged In: YES
    user_id=1449836
    Originator: NO

    Thanks a lot!

    Works fine with FF, but no effect for IE7. But stopPropagation does the trick for IE too.
    Have added the code.

    Thanks
    Patrick

     
  • Patrick Wolf
    Patrick Wolf
    2007-12-06

    • milestone: --> v1.9
    • assigned_to: nobody --> patrick_wolf
    • status: open --> closed