So, if i understood right you want to make a custom vertical Scrollbar?

In that case it has few steps:
1.You need to know cursor position on each frame, and store the location at the end of the frame. At beginning of new frame you calculate delta with MouseY-oldMouseY (this is how much the mouse moved)
2.When mouse is first pressed down: Calculate if cursor hits the scrollbar rectangle. If it does, set a new variable Scrolling:=true.
3.When mouse is moved and Scrolling = true, move the rectangle vertically by delta.
4.When mouse is released: Set variable scrolling:=false again.