[?] Locator constrained by polygon and NSolve

Dear Community,

I have a polygon with a constrained locator in it. I would like to draw a horizontal line from the locator towards the left boundary of the polygon, which is also given by a stewise function called qgHSZ. I try to achieve this with NSolve, but I get some strange warnings, like

“Part 2 of {0.5,10.} does not exist” Why??
“NSolve was unable to solve the system with inexact coeficients, etc.” Not clear either. If I test NSolve below the plot, it works fine.

What do I do wrong? Notebook attached.
Tx for the kind help in advance,
regards, Andras

This seems to work:

DynamicModule[{pt = {0.5, qgHSZ[.2]}, from = .2, x},
 {Graphics[{Dynamic[Line[{{from , pt[[2]]}, pt}]],
    LightBlue, Opacity[0.9], Polygon[pts],
    Locator[
     Dynamic[pt , (pt = RegionNearest[Polygon[pts], #]; 
        from =  x /. NSolve[ qgHSZ[x] == pt[[2]], x][[1]]) &]]},
   Axes -> True, AspectRatio -> 1], Dynamic[pt]}]

Dear Gianluca,

Works beautifully, exactly as I wanted :slight_smile:

Tx very much,
best regards
Andras