I got help from Kuba on a previous post regarding this issue I'm having but after integrating that solution into my code, the problem changed and I am left with something I don't know much about (even after some research) so here I am again. Here is the link to my first post. The edit I added is what is shown below, it was suggested that I just ask the question in a new post though.
What I would like to happen is that when the black dot crosses the curve, the label changes from "vapor" to "liquid" and vice versa and that label should not change when the point moves around the curve. Right now Kuba's solution works, but only if the mouse is NOT depressed (meaning the point will not move). I tried using AutoAction->True
but it slowed down my notebook quite a bit.
Below is a very simplified version of the notebook I am working with that has Kuba's solution integrated into it.
Manipulate[
DynamicModule[{col = False, acc = 0, p = {420, Log[6]}},
EventHandler[
Show[Quiet@
LogPlot[Log[T], {T, 273.16, 647.096}, PlotStyle -> Thick] /.
l_Line :>
EventHandler[
l, {"MouseEntered" :>
If[acc ===
0, (col = col /. {True -> False, False -> True})]}],
Frame -> True, PlotRange -> {{273.16, 700}, {Log[5.6], Log[7]}},
Epilog ->
Inset[Graphics[
Text[Style[Dynamic@If[col == True, "liquid", "vapor"], 18],
Scaled[{0.400, 0.1}]]]]], {"MouseDown" :> (acc = 1;
MousePosition[Dynamic@p]),
"MouseDragged" :> (MousePosition[Dynamic@p]),
"MouseUp" :> (acc = 0; MousePosition[Dynamic@p])},
PassEventsDown -> True]], {{p, {420, Log[5.75]}}, Locator,
Appearance -> Graphics[{Disk[]}, ImageSize -> 12]}]
I am trying to make a Demonstration that shows the behavior of water on a pressure vs. temperature diagram so I need to show that there is only a phase change from vapor to liquid/liquid to vapor if the phase boundary is crossed.
It's important that Manipulate
remains a part of this code.