7
$\begingroup$

Bug introduced in V10.1 or earlier and persisting through V11.3


Print is triggered just by pressing the mouse button.

 EventHandler[Framed[1], {"MouseDragged" :> (Print@RandomReal[])}]

Documentation claims something else:

"MouseDragged" mouse moving with primary button depressed


Bug confirmed by WRI

$\endgroup$
  • 5
    $\begingroup$ It's a painful punishment administered in the modern workplace to poor team players that are adversely affecting morale. "John refused to collaborate with Karen and the project was behind schedule, so his colleagues mousedragged him across the carpet until he agreed to cooperate". $\endgroup$ – Daniel Lichtblau Jan 27 '15 at 16:36
  • 1
    $\begingroup$ J. Cwi.. or J. Fu..? $\endgroup$ – Rolf Mertig Jan 27 '15 at 17:30
  • 1
    $\begingroup$ (1) The former would be more likely to actually do the dragging. In point of fact he used to own a dragon. A Komodo Dragon, which is about the deadliest pet known to mankind. Rolf, I work with lunatics. $\endgroup$ – Daniel Lichtblau Jan 27 '15 at 21:54
  • $\begingroup$ (2) And the latter is my manager. He's as confused about this state of affairs as I am. $\endgroup$ – Daniel Lichtblau Jan 27 '15 at 21:55
  • $\begingroup$ Ah, so this is why Peter K. wrote in his BETTIME STORY that "fuelling can be done only during full moon." $\endgroup$ – Rolf Mertig Jan 27 '15 at 22:08
3
$\begingroup$

If it were a venn diagram, clicked would be a subset of dragged (at least in the mind of whoever implemented this). You can reproduce what (I think) you want by adding a null event for "clicked":

EventHandler[
 Framed[1], {"MouseClicked" :> Null, 
  "MouseDragged" :> (Print@RandomReal[])}]

---EDIT--- Or, for that matter, as per your comment, it is weird this works since clicked is triggered at release. Anyhow, the more sensible "MouseDown" works just as well.

$\endgroup$
  • $\begingroup$ It would have been consistent if you have added "MouseDown" not "MouseClicked" since the latter is triggered after releasing the button. But "MouseDown" is not a fix so I don't get it! :) Nevertheless it works so thanks :) $\endgroup$ – Kuba Jan 22 '15 at 11:26
  • $\begingroup$ Damn - you're right! My lack of experience with events shows :) $\endgroup$ – gpap Jan 22 '15 at 11:31
  • $\begingroup$ Wow, try this! Switch focus to MessageNB e.g. And click directly on your even handler from there. Now do this again but first switching focus to main NB with clicking on it's frame e.g. $\endgroup$ – Kuba Jan 22 '15 at 11:37
  • $\begingroup$ I don't understand. It behaves the way I expect it to (if focus is not on the notebook with the code, nothing happens). I am on OSX and v10.0.2 for the record $\endgroup$ – gpap Jan 22 '15 at 11:49
  • $\begingroup$ When I switch focus to MessagesNotebook, and then directly click and keep pressed our EventHandler in main notebook, tt keeps printig numbers... Win7 10.0.2. $\endgroup$ – Kuba Jan 22 '15 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.