Is there a way to detect double click events? I did not find anything on the doc page of EventHandler
.
Use case: I want to re-implement the Crop Image...
functionality available form the context menu when clicking images. The cropping GUI appears much too slowly with even moderately large images, such as screenshots of the full screen. Although I could use a button to crop, I'd prefer using double click, just like in the original implementation.
Answer
You can use a combination of MouseDown
and MouseClickCount
as in the following examples:
example 1: double-click increments the value of j
:
j = 1; EventHandler[Panel[Dynamic[j]],
"MouseDown" :> If[CurrentValue["MouseClickCount"] == 2, ++j]]
example 2: double-click toggles the text color:
DynamicModule[{col = Green},
EventHandler[
Style["text", FontColor -> Dynamic[col]],
{"MouseDown" :>
If[CurrentValue["MouseClickCount"] == 2,
(col = col /. {Red -> Green, Green -> Red})]}
]]
Comments
Post a Comment