I actually found one possible solution, however it doesn't work.
Let's see:

For each line there's a mathematical function with that form:

y = k * x + n

y= y coord; x = x coord; n = number; k = static variable

Following function is the same as above, it just uses 2 coordinates (x, x1, y, y1)

y - y1 = k * (x - x1) ---> y = k * (x - x1) + y1

Point is that here we do not have k, so we have to calculate it. This is done by next function:

k = (y2 - y1) / (x2 - x1)

Now we have k, both coordinates and function for that line. And even now I cannot find out if I clicked on a line.

Any suggestions?