I am trying to convert 2d coordinates of mouse to 3d

Sure,

Please see this.

Here i also want to learn how to manage the cursor because my cursor always far from the line.

Thanks