tags:

views:

407

answers:

2

I tried to follow the widget example by mindtrove's blog. Here is the example demo page.

There are some problems with this widget: left & right arrow keys, and home & end keys are not working in Firefox(I am using a Mac), and none of any keys are working if I load the example page in Safari. I am not sure if this is only my Mac's problem or not working on Mac at all.

Here are some codes in the widget Rating.js:

    _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 see, all the keys cought in this function event should work. I am not sure why some are not working. By the way, I find out one thing interesting: for those keys (left, right, home & end) keys in Firefox, they works if I hold my shift key.

I am not sure if the problem is a bug in the widget's codes or Dojo's bug in case of Mac?

A: 

Typical Dojo behaviour. What "class" does this one extend? You can check if it's "base class" exhibits the same bugs. But in the case of Dojo you can never be sure where bugs come from, you can only be sure there are tons of them.

Vasil
A: 

Actually, I found out all the keys are working in Firefox(Mac). I am using Vimperator to mark up some keys. When I get it in "Pass-through" mode, which means no keys are trapped by Vimerator add-on, the focused Rating control widget will get key events with left, right, up, down, home & End.

At least in case of Firefox, the widget is working. From my experience, the widget provides some event functions for the control when it is focused. However, if there are any add-ons or browser configurations that cause events not passing through or they respond to the events, then you will get the "problem". In other words, if it is really complicated in browser case. I can image that if some add-ons could disable mouse click event, the widget would not work any more.

Still I could not figure out to make the widget working in my Safari. From what I can see, the widget control does not get any focused at all. The widget is assigned to a span tag in the test page. I am not sure if span tag could get focus in Safari or not. I'll see if I could get the widget to another focusable tag or not and give it a try.

It is really rewarding to get something working and to explore.

David.Chu.ca