Re: PopupWindow vs EventHandler
- To: mathgroup at smc.vnet.net
- Subject: [mg117511] Re: PopupWindow vs EventHandler
- From: John Fultz <jfultz at wolfram.com>
- Date: Mon, 21 Mar 2011 06:15:36 -0500 (EST)
To copy/paste plots out of a PopupWindow, you need to add the following options to PopupWindow: WindowFrame -> "Normal", WindowFloating -> False The problem you're having with EventHandler can be solved in two different ways. One way is to store the data in a DynamicModule, which will always refresh the kernel. event[point_] := DynamicModule[{mydata = data}, EventHandler[Tooltip[Point[point], "EventHandler"], "MouseClicked" :> CreateDocument[ListPlot[mydata], WindowSize -> All]]] The other possibility is to consider it an issue of evaluation order. RuleDelayed is preventing 'data' from evaluating immediately, thereby preserving the dependency upon the named symbol "data". You can use With[] to punch a hole through RuleDelayed and get the fully evaluated version of "data" in there. I.e., event[point_] := With[{data = data}, EventHandler[Tooltip[Point[point], "EventHandler"], "MouseClicked" :> CreateDocument[ListPlot[data], WindowSize -> All]]] Sincerely, John Fultz jfultz at wolfram.com User Interface Group Wolfram Research, Inc. On Sun, 20 Mar 2011 04:53:22 -0500 (EST), Thomas M=FCnch wrote: > Dear Group, > > Below is a simplified version to illustrate my problem. The code below > will create a simple graph with a red and blue point. When you click on > the points, a popup-window will open to present a plot of the "data". > The red dot does this with an EventHandler[], and the blue dot with a > PopupWindow[]. > > data == Table[Sin[x], {x, 0, 10}]; > event[point_] :== > EventHandler[Tooltip[Point[point], "EventHandler"], > "MouseClicked" :> > CreateDocument[ListPlot[data], WindowSize -> All]]; > pop[point_] :== > PopupWindow[Tooltip[Point[point], "Popup"], ListPlot[data], > WindowSize -> All]; > Graphics[{PointSize[Large], Red, event[{0, 1}], Blue, pop[{1, 1}]}, > AspectRatio -> Full, ImageSize -> {50, 20}] > > There is the following problem: The plot in the PopupWindow can be > selected, but cannot copied-and-pasted somewhere else. This is something > that I would like to be able to do. > With the Plot in the other window (EventHandler), this is possible. > However, if you now Quit[] the kernel (i.e. Mathematica forgets about > the definition of data), the EventHandler does not produce the plot > anymore, while the PopupWindow still works. > > I'd like to be able to do one of the following: > - copy-and-paste plots out of the PopupWindow, > or: > - have the EventHandler remember the data in a fresh Mathematica session. > > Some background: I analyze data, where the points represent some > condensed properties of data. Clicking the points should show the > original data, with the possibility to extract the original-data plot > (copy-and-paste) for further inspection. > > Thank you! > thomas