This project is archived and is in readonly mode.

#280 ✓resolved
Michal

Adding custom keypress interferes with default shortcut keys in Firefox 2 and Safari 3 Mac

Reported by Michal | July 30th, 2008 @ 05:09 PM | in 1.2.1

Adding a custom event based on keypress, e.g. "left":

Element.Events.left = {
    base: 'keypress', 
    condition: function(event){
        return (event.key == "left");
    }
};
window.addEvent('left', function(){
	alert("Test");
});

block certain keyboard shortcuts in Firefox 2 and Safari 3 Mac.

In Firefox

"Apple Key" + "+" should increase font-size. It does nothing with the added event.

In Safari

"Apple Key" + "+" should decrease font-size

"Apple Key" + "t" should open a new tab.

Both of these do not work with the added event.

In both Safari and Firefox the shortcut keys in other currently open tabs work properly.

Comments and changes to this ticket

  • Michal

    Michal July 30th, 2008 @ 05:16 PM

    In Firefox 3 on Mac I have just discovered, the situation is even worse, I can't find a single shortcut key that works with the custom event.

    (Although the correct top-level menu "flashes blue" when a shortcut key is pressed. E.g. for apple+t for a new tab, the File menu flashes, but no new tab appears. For apple+-, for decreasing font size, the view menu flashes, but the font size does not change).

  • Michal

    Michal July 30th, 2008 @ 06:07 PM

    • no changes were found...
  • Jan Kassens

    Jan Kassens July 30th, 2008 @ 08:25 PM

    • Assigned user changed from “Valerio” to “Jan Kassens”
    • State changed from “new” to “open”
    • Tag changed from 1.2, 1.2release, defect, events, firefox to 1.2, core, defect, events, firefox
  • Sebastian Markbåge

    Sebastian Markbåge August 26th, 2008 @ 02:19 PM

    It seems to me that this is related to custom conditions stopping propagation (and also prevents default).

    See ticket 337: http://mootools.lighthouseapp.co...

  • Sebastian Markbåge

    Sebastian Markbåge August 26th, 2008 @ 02:24 PM

    Just to clarify the issue here...

    
        condition: function(event){
            return (event.key == "left");
        }
    

    When this condition returns false, event.stop() is called by MooTools. Therefore preventDefault() is called and all keypresses (except "left") are blocked. IMO, this is a bug, since condition return false shouldn't call event.stop() at all.

  • UloPe

    UloPe September 5th, 2008 @ 04:04 PM

    • Tag changed from 1.2, core, defect, events, firefox to 1.2, core, defect, events, firefox, patch

    I can confirm this bug.

    The following patch fixes this for me:

    
    Index: mootools-1.2-core.js
    ===================================================================
    --- mootools-1.2-core.js
    +++ mootools-1.2-core.js
    @@ -1838,7 +1838,7 @@
     			if (custom.condition){
     				condition = function(event){
     					if (custom.condition.call(this, event)) return fn.call(this, event);
    -					return false;
    +					return true;
     				};
     			}
     			realType = custom.base || realType;
    
  • Jan Kassens

    Jan Kassens October 1st, 2008 @ 01:51 AM

    • State changed from “open” to “resolved”
    • Milestone changed from 2.0 to 1.2.1
    • Tag changed from 1.2, core, defect, events, firefox, patch to defect, events, firefox, patch

    fixed in master, thanks UloPe for the patch.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Attachments

Pages