Making a button slider

like photoshop cs3 has, flash cs4 also… and probably some others…

a textfield which acts like a button and when you press and hold down the mouse and move up or right the value increases and when you move down or left value decreases.

a need a suggestion how to do this the most efficiently…
on a mouse_down how would I track where the mouse is moving and how much it has moved in what direction so i can ajust the value in the textfield?