MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Locators and Dynamic

  • To: mathgroup at
  • Subject: [mg89397] Locators and Dynamic
  • From: Ekta Obheroi <ektaobheroi at>
  • Date: Sun, 8 Jun 2008 02:32:50 -0400 (EDT)

Hi everyone,
I have a question regarding locators being used with Dynamic. I have the following scenario:

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:
 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

  • Prev by Date: Re: Major problem with
  • Next by Date: Re: Major problem with
  • Previous by thread: Re: color depth of eps export
  • Next by thread: Re: Locators and Dynamic