Some keys not working with Dojo widgets

I tried following the example widget on mindtrove blog . Here is a sample demo page .

There are some problems with this widget: the left and right arrow keys and the home and destination keys do not work in Firefox (I am using a Mac) and none of the keys work if I load the example page in Safari.I’m not sure if is it just my problem with Mac or not working at all on Mac.

Here are some codes in Rating.js widgets:

_onKeyDown: function(event) {
    switch(event.keyCode) {
    case dojo.keys.UP_ARROW:
    case dojo.keys.RIGHT_ARROW:
        this.currentValue += 1
        this.currentValue = Math.min(this.currentValue, this.maximumValue);
        dojo.stopEvent(event);
        break;
    case dojo.keys.DOWN_ARROW:
    case dojo.keys.LEFT_ARROW:
        this.currentValue -= 1
        this.currentValue = Math.max(this.currentValue, this.minimumValue);
        dojo.stopEvent(event);
        break;
    case dojo.keys.HOME:
        this.currentValue = this.minimumValue;
        dojo.stopEvent(event);
        break;
    case dojo.keys.END:
        this.currentValue = this.maximumValue;
        dojo.stopEvent(event);
        break;
    }
    // refresh the display
    this._update();
}

      

As far as I can tell, all keys typed in this functional event should work. I'm not sure why some of them don't work. By the way, I find out one interesting thing: for keys keys (left, right, for home and for end) in Firefox they work if I hold the shift key.

I'm not sure if the problem is due to a bug in the widget code or a Dojo bug in the case of a Mac?

+1


source to share


1 answer


In fact, I found out that all keys work in Firefox (Mac). I am using Vimperator to mark up some keys. When I get it in "Pass-through", which means no keys are trapped over the Vimerator addon, the focused control widget will receive key events from the left, right, up, down, home and end.

At least in the case of Firefox, the widget works. In my experience, the widget provides some event functions to control when it is focused. However, if there are any browser add-ons or configurations that trigger events that do not pass or respond to events, then you will get a "problem". In other words, if it's really tricky in the case of a browser. I can imagine that if some add-ons can disable the mouse click event, the widget won't work anymore.



However, I could not figure out how the widget would work in my Safari. From what I can see the widget control is not focusing at all. The widget is assigned to the span tag on the test page. I'm not sure if span tag can get focus in Safari or not. I'll see if I can get the widget on a different custom tag or not and try it.

It's really helpful to get something working and learn.

0


source







All Articles