I think you should setup an array of X, Y positions that represent the center of your square boxes.

Then you have to figure out when to register a click on a number and when to register a click on a line or junction. Let’s say your numbers are 1 unit apart (0x,0y is a square, 0,1 is a square, 1,0 is a square, 1,1 is a square, etc.), now you can find the closest square, 2nd closest square, 3rd closest square, 4th closest square to the user click by means of a for loop, looping through the array of x positions and y positions.

Then, if for example the click was at a distance of more than 0.3f away from the center of the closest square in the X or the Y (you’ll have to play with this value to find the sweet spot, but let’s just say that an offset of 0.3f in the y or 0.3f in the x is considered off the square, giving your square 0.6f in the x and 0.6f in the y directions to register a click), now you know that you are clicking on a line or junction.

Now if the click is more than 0.3f in the y and more than 0.3f in the x, you are at a junction, if it is only more than 0.3f in one direction, you are at a line. To find which line, you just need to know if the direction at which is more than 0.3f is more or less than the, let’s say the y direction. If it is more, than the line is above, if less, the line is below.

For finding the junction, it’s easy, you already know which 4 squares are closest, so it’s the junction between them.