Hi everyone,
I have a question regarding locators being used with Dynamic. I have the following scenario:
height=833;
width = 1440;
(*Create a notebook randomly on the screen*)
nb = NotebookCreate[WindowSize -> {240, 240},
WindowMargins -> {{RandomInteger[{0, width}], Automatic}, {Automatic,
RandomInteger[{0, height}]}}]
(*Get the x and y coordinates of the position of the notebooks*)
getCoords[nb_] := {#1, height - #2} & @@ Flatten[WindowMargins /. Options[nb]][[{1, -1}]]
What I would like to do now is, if I move the newly created notebook anywhere on the screen, I would like to have x and y coordinates print to the screen dynamically.
I tried the following:
DynamicModule[{},
Dynamic[ getCoords[nb]]
]
When I run this the first time, it works. However, when I move the notebook (nb) it does not update the value on the screen.
Please let me know how this can be accomplished.
Thanks very much