Skip to forum content

Mif

— mystic javascript interface

You are not logged in. Please login or register.


Post new reply

Post new reply

Compose and post your new reply

You may use: BBCode Images Smilies

All fields labelled (Required) must be completed before the form is submitted.

Required information for guests



Captcha image. Turn pictures on to see it.
Required information
Optional post settings

Topic review (newest first)

1

Thank you moro, mousedown was the event I was looking for! Works great even with IE now smile

2

mb mousedown ?

3

Thank you for replying so quickly smile

That works if the user actually scrolls but not if he only clicks on the scroll bar (since no actual scroll event are sent).

Is there a way to catch a click on that scroll bar ? I've tried this:

new Mif.Tree({

    initialize: function(){
        this.wrapper.addEvent('click', function(){
            alert('click');
        });
    },
    ...

});

But only clicks on the div of the wrapper are caught, not on the scroll bar sad

4

as i'm understand you want something like this:

new Mif.Tree({

    initialize: function(){
        this.wrapper.addEvent('scroll', function(){
            alert('scroll');
        });
    },
    ...

});

5

Hi Moro,

How can I catch the onscroll event ?

My real problem is the following:
I have an input that, when the user sets focus on it, I open a pop-up with a Mif.Tree in it.
The user can then select an item in the tree and it will fill in the input with the corresponding item path. The thing is, on the blur event of the input, I hide this pop-up. In order to prevent the Mif.Tree pop-up from disappearing when the user clicks on an item, I set a timer on the blur of the input as follows:

--------8<---------------------------
    /*...*/
    'focus': function(){
        $clear(blur_timer);
        dirSelector.setInput(this);
        dirSelector.show();
    }
    'blur': function(){
        blur_timer = function() {
            dirSelector.hide();
        }.delay(200, this);
    }
    /*...*/
--------8<---------------------------


And my class that derives from Mif.Tree, I do the following:

--------8<---------------------------
var DirectorySelector = new Class({
    Extends: Mif.Tree,
    /*...*/
    setInput: function(input){
        this.options.input = $(input);
    },
    show: function(){
        this.options.container.setStyle('height', '0');
        this.updatePosition();
        new Fx.Tween(this.options.container).start('height', 0, 200);
    },
    hide: function(){
        this.options.container.setStyles({'top': '-1000px', 'height': '0'});
    },
    toggleClick: function(event){
        // Force focus to input
        this.options.input.blur();
        (function() {this.options.input.focus();}).delay(1, this);
        this.parent(event);
    }
});
--------8<---------------------------

As you can see, clicking an item of the tree sets the focus back to the input. This works fine with all browsers except with IE when I try to scroll, the input loses focus and so the pop-up disappears.

This is why I ask: who can I catch the onscroll event in order to force focus back to the input ?

Thank you for your time.
Cheers,
Peter