Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have two level EventHandler. The inner one is made of vertex of Graph and the other outer one is of the Dynamic Graph.

(1) If I select a arbitray place on the Graph except a vertex, then every thing is OK, but

(2) if I select the vertex after restart this code, then dragging process is sttoped I don't know why it is doing like this.

If I remove MouseDown of vertex eventhandler in this code, then the process is ok. but I want to make some action after vertex MouseDown. Is there something help! thank you.

DynamicModule[{vlist, elist, p, mousep, select},
 vlist = EventHandler[#, {
      "MouseDown" :> AppendTo[e, 1],
      "MouseDragged" :> AppendTo[e, 2]}] & /@ Range[3];
 elist = {1 -> 2, 2 -> 3, 3 -> 1, 1 -> 3};
 p = {{-.5, -.2}, {.5, -.2}, {0, .5}};e = {};
 EventHandler[
  Dynamic[
   Graph[vlist, elist, VertexCoordinates -> p, VertexSize -> {.15, .15},
     VertexLabels -> "Name", PlotRange -> 1]],
  {"MouseDown" :> (AppendTo[e, 3];
     mousep = MousePosition["Graphics"];
     select = Position[p, Nearest[p, mousep][[1]]][[1, 1]]),
   "MouseDragged" :> (AppendTo[e, 4];
     p[[select]] = MousePosition["Graphics"]),
   "MouseUp" :> (Print[Short[e, 1]]; e = {})}, PassEventsDown -> True]
 ]
share|improve this question
    
You should take a look here –  Öskå Jul 16 at 12:33
    
@Öskå thank you for my discpting. but I want to know some missing of this code with two MouseDown. –  Junho Lee Jul 16 at 12:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.