This is a migrated thread and some comments may be shown as answers.

[Solved] mousewheel support

0 Answers 56 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wade
Top achievements
Rank 1
Wade asked on 11 May 2010, 12:03 AM
I couldn't find where the numeric textbox supported mousewheel support, and I wanted mine to be able to handle:
I added the following to the telerik.textbox.min.js and all seems good :)
original section:
            value: (i || this.text) }).bind({  
                blur: b.delegate(thisthis.blur), 
                focus: b.delegate(thisthis.focus), 
                keydown: b.delegate(thisthis.keydown), 
                keypress: b.delegate(thisthis.keypress), 
                change: function (m)  
                { 
                    m.stopPropagation(); 
                    return false 
                } 
            }).bind(f, b.delegate(thisthis[f])).insertAfter(h); 
        var k = c(".t-arrow-up, .t-arrow-down", g).bind({ 
            mouseup: b.delegate(thisthis.clearTimer), 
            mouseout: b.delegate(thisthis.clearTimer), 
            click: b.preventDefault, 
            dragstart: b.preventDefault, 
            dblclick: b.delegate(thisthis.clearTimer) 
 
Modified to:
            value: (i || this.text) }).bind({  
                blur: b.delegate(thisthis.blur), 
                focus: b.delegate(thisthis.focus), 
                keydown: b.delegate(thisthis.keydown), 
                keypress: b.delegate(thisthis.keypress), 
                mousewheel: b.delegate(thisthis.mouseWheel), 
                DOMMouseScroll: b.delegate(thisthis.mouseWheel), 
                change: function (m)  
                { 
                    m.stopPropagation(); 
                    return false 
                } 
            }).bind(f, b.delegate(thisthis[f])).insertAfter(h); 
        var k = c(".t-arrow-up, .t-arrow-down", g).bind({ 
            mouseup: b.delegate(thisthis.clearTimer), 
            mouseout: b.delegate(thisthis.clearTimer), 
            click: b.preventDefault, 
            dragstart: b.preventDefault, 
            mousewheel: b.delegate(thisthis.mouseWheel), 
            DOMMouseScroll: b.delegate(thisthis.mouseWheel), 
            dblclick: b.delegate(thisthis.clearTimer) 
 
Added the following to the prototype section of the code:
        mouseWheel: function (event) 
        { 
            if (this.focus)  
            { 
                var delta; 
                var rawEvent = event; 
                if (rawEvent.wheelDelta) { 
                    // IE and Opera use wheelDelta, which is a multiple of 120 (possible values -120, 0, 120). 
                    delta = rawEvent.wheelDelta / 120; 
                    // In Opera, value is negated. 
                    //if (Sys.Browser.agent === Sys.Browser.Opera) delta = -delta; 
                } 
                else if (rawEvent.detail) { 
                    // Firefox uses detail property, which is a multiple of 3. 
                    delta = -rawEvent.detail / 3; 
                } 
                if (delta > 0) 
                    this.stepper(event,1); 
                else if (delta < 0) 
                    this.stepper(event,-1); 
                this.clearTimer(event); 
            } 
        }, 
 

Hopefully someone else can use or it will make its way into the next version.  Thank you Telerik for providing the MVC code under OpenSource!  I for one appreciate it.


Tags
NumericTextBox
Asked by
Wade
Top achievements
Rank 1
Share this question
or