Yet another blog about WPF, Surface, SL, MVVM, NUI.... - Tag - TimeLine - Comments http://blog.lexique-du-net.com/index.php? In this blog we talk about WPF, Natural User Interface(NUI), Microsoft Surface, WIndows 7, Multitouch, Touchless, JavaFX, MVVM, patterns, tips, tricks .... and a lot of other things ! en Mon, 26 Feb 2024 15:40:43 +0100 Jonathan ANTOINE, All rights reserved http://blogs.law.harvard.edu/tech/rss Dotclear how do I detect double clic in JavaFX ? - Jonathan ANTOINE http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c21 urn:md5:7ca0d164624324cf0f0cd586d9cd00a8 Mon, 15 Dec 2008 21:25:51 +0100 Jonathan ANTOINE <p>@<a href="http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c20" rel="nofollow">David Karr</a> : I fully agree with you ^^ !</p> how do I detect double clic in JavaFX ? - David Karr http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c20 urn:md5:4bb9a70cce949cd330b75047bcc048de Mon, 15 Dec 2008 19:04:05 +0100 David Karr <p>I would point out that double-click functionality should always be an extension of the single-click functionality. That is how user interfaces are designed, and you shouldn't try to avoid it. Users will expect a double-click to perform the single-click functionality, and then the double-click extension. If you violate that expectation, users will be surprised and confused. The principle of "least surprise" is very important in user interfaces.</p> how do I detect double clic in JavaFX ? - Roger Padilla http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c19 urn:md5:54e4b626dec5df6a2839587e2b91fb17 Sun, 14 Dec 2008 19:11:50 +0100 Roger Padilla <p>Absolutely Your are not, the mad was Me <img src="themes/default/smilies/wink.png" alt=";)" class="smiley" /></p> how do I detect double clic in JavaFX ? - Jonathan ANTOINE http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c18 urn:md5:a83b4d6478f70742047ca15260498047 Sun, 14 Dec 2008 19:00:03 +0100 Jonathan ANTOINE <p>@<a href="http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c17" rel="nofollow">Roger Padilla</a> : </p> Ouf, I was thinking I was mad ^^ how do I detect double clic in JavaFX ? - Roger Padilla http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c17 urn:md5:afdde959e083bd19d42281fdac6ad495 Sun, 14 Dec 2008 18:58:59 +0100 Roger Padilla <p>Ohh yes!, You are right and I'm wrong, my fail, sorry. That is a not implemented feature.<br /> You have the solution <img src="themes/default/smilies/smile.png" alt=":)" class="smiley" /></p> how do I detect double clic in JavaFX ? - Jonathan ANTOINE http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c16 urn:md5:b446c496e0dd523ad84a7b245abd2567 Sun, 14 Dec 2008 18:34:55 +0100 Jonathan ANTOINE <p>@<a href="http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c14" rel="nofollow">Mauro</a> : The proble seems to be the same with Swing :</p> <ol><li>First link :<a href="http://objectmix.com/java/72551-how-detect-double-click-mouse-events-swing.html" rel="nofollow">check this link.</a>  </li> <li>Second link : <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&amp;f=2&amp;t=014225" hreflang="en" rel="nofollow">Here too</a></li> </ol> <br /> how do I detect double clic in JavaFX ? - Jonathan ANTOINE http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c15 urn:md5:97d0e05b32b4066bb1ef800ca15c955d Sun, 14 Dec 2008 18:31:39 +0100 Jonathan ANTOINE <p>@<a href="http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c13" rel="nofollow">Roger Padilla</a> : You will sure perform the doubleclick action but also the firstClick action: I don't want this !</p> <p>I let you check this little app : <a href="http://www.lexique-du-net.com/javafx/ClickApp.zip" hreflang="en" rel="nofollow">http://www.lexique-du-net.com/javafx/ClickApp.zip</a></p> <p>This app just add "simple" or "double" to a text when click are done using your code...</p> how do I detect double clic in JavaFX ? - Mauro http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c14 urn:md5:a689f6ec18d427fb6266a0d010ef3360 Sun, 14 Dec 2008 18:29:02 +0100 Mauro <p>You don't need to do that in Java/Swing neither in JavaFX.</p> how do I detect double clic in JavaFX ? - Roger Padilla http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c13 urn:md5:51e4b1b6e5f5a077bcfb5250a6fc567c Sun, 14 Dec 2008 18:24:34 +0100 Roger Padilla <p>@"By doing this you will perform simpleClick each time you will make a double click: on the first click of your double..."</p> <p>Not because of "clickCount" is a sum value which is controlled in background.</p> how do I detect double clic in JavaFX ? - Roger Padilla http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c12 urn:md5:cdebd39454eb47d491b60aa9a06e3933 Sun, 14 Dec 2008 18:22:48 +0100 Roger Padilla <p>@"What I want is :</p> <p>* To perform a simpleClick action on single click only (and not those which are part of a double click),<br /> * To perform a double click action on doubleClick only."</p> <p>That is just what the "if-else" approach does <img src="themes/default/smilies/smile.png" alt=":)" class="smiley" /></p> <p>This will works for you:</p> <p>onMouseClicked: function(me:MouseEvent){<br /> if(me.clickCount &gt;= 2){<br /> doubleClick();<br /> } else {<br /> simpleClick();<br /> }<br /> }</p> how do I detect double clic in JavaFX ? - Jonathan ANTOINE http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c11 urn:md5:587ebd079d8e14ec85a72cbd4d95db58 Sun, 14 Dec 2008 18:22:00 +0100 Jonathan ANTOINE <p>@<a href="http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c10" rel="nofollow">Roger Padilla</a> : </p> By doing this you will perform simpleClick each time you will make a double click:<span class="Apple-style-span" style="font-style: italic;"> on the first click of your double click...</span> how do I detect double clic in JavaFX ? - Roger Padilla http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c10 urn:md5:15a411397b3aa66c7e8ca44f3306656c Sun, 14 Dec 2008 18:18:29 +0100 Roger Padilla <p>onMouseClicked: function(me:MouseEvent){<br /> if(me.clickCount &gt;= 2){<br /> doubleClick();<br /> } else {<br /> simpleClick();<br /> }<br /> }</p> how do I detect double clic in JavaFX ? - Jonathan ANTOINE http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c9 urn:md5:091cf34d04168eefa77d4f1a04929d4f Sun, 14 Dec 2008 18:16:23 +0100 Jonathan ANTOINE <p>@<a href="http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c8" rel="nofollow">Roger Padilla</a> : </p> <p><span class="Apple-style-span" style="border-collapse: collapse; font-family: 'Andale Mono'; font-size: 9px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br /></span></p> <p><span class="Apple-style-span" style="border-collapse: collapse; font-family: 'Andale Mono'; font-size: 9px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">I got the point but :</span></p> <p><span class="Apple-style-span" style="border-collapse: collapse; font-family: 'Andale Mono'; font-size: 9px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">When you make a double click, you click twice, so this is what will occurs:</span></p> <ol><li>The first click will be catch and the simpleClickAction will be done (because clickCount != 2) <span class="Apple-style-span" style="font-weight: bold;">---> I don't want it : this is a double click and I want the simpleClick action to be perform only on single click !!</span>,</li> <li>The second click will be catcj and the double clickAction will be done --> This is what I want.</li> </ol> <div>...</div><div>What I want is :</div><div><ul><li>To perform a simpleClick action <span class="Apple-style-span" style="font-weight: bold;">on single click only (and not those which are part of a double click),</span></li> <li>To perform a double click action on doubleClick only.</li> </ul> </div> how do I detect double clic in JavaFX ? - Roger Padilla http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c8 urn:md5:02d40e350d5f24cba8d7dd0d02a62845 Sun, 14 Dec 2008 18:04:26 +0100 Roger Padilla <p>You does not understand, that is an "if-else", so, if it goes inside the 'if' it will never goes inside the 'else' at the same time. In the below code, if it is a double click it will never read as a single click and vice-versa.</p> <p>if(ev.clickCount &gt;= 2){<br /> // Process Double Click<br /> } else {<br /> // Process Single Click<br /> }</p> how do I detect double clic in JavaFX ? - Jonathan ANTOINE http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c7 urn:md5:02c8323ec5508474f880af58ddec889a Sun, 14 Dec 2008 17:26:45 +0100 Jonathan ANTOINE <p>@<a href="http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c6" rel="nofollow">Roger Padilla</a> : If I do this, the simpleClick action will be done each time:</p> <ul><li>If it's a double click, it will be done on the first click, </li> <li>If it's a simpleclick, it will of course be done.</li> </ul> <div>This is it because when you double click, the mouse event is launch twice: one with clickCount=1 and one with clickCount =2.</div> how do I detect double clic in JavaFX ? - Roger Padilla http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c5 urn:md5:80c4c1e8b3230a095826f6324353e5c2 Sun, 14 Dec 2008 17:03:25 +0100 Roger Padilla <p>That is not right, just do:</p> <p>if(ev.clickCount == 2){<br /> // Process Double Click<br /> } else {<br /> // Process Single Click<br /> }</p> <p><span class="Apple-style-span" style="border-collapse: collapse; font-size: 11px; line-height: 15px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><p style="margin-top: 0; margin-right: 0; margin-bottom: 1em; margin-left: 0; ">Or:</p> <p style="margin-top: 0; margin-right: 0; margin-bottom: 1em; margin-left: 0; ">if(ev.clickCount >= 2){<br />// Process Double Click<br />} else {<br />// Process Single Click<br />}</p> <p style="margin-top: 0; margin-right: 0; margin-bottom: 1em; margin-left: 0; ">The time is auto-restarted.</p> <p style="margin-top: 0; margin-right: 0; margin-bottom: 1em; margin-left: 0; ">Ps: Edited by Jonathan : I grouped together your 2 comments.</p> </span></p> how do I detect double clic in JavaFX ? - Jonathan ANTOINE http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c4 urn:md5:8a1bbe1035dffc3433b3301579cb6f30 Sun, 14 Dec 2008 16:47:52 +0100 Jonathan ANTOINE <p>pavan: </p> <p>Hey,</p> <p>I can use this property but if I do this the simpleClick action will be done each time. %%%</p> <p>The behavior of the click event is execute the function with clickCount=1 then execute the function again with clickCount = 2. %%%</p> <p>So if you want to execute a differente function on simple click and on double click, you can't only do this.</p> <p>+ + +</p> how do I detect double clic in JavaFX ? - pavan http://blog.lexique-du-net.com/index.php?post/2008/12/14/how-do-I-detect-double-clic-in-JavaFX#c3 urn:md5:bd919a892ba549376b2cc777d43de94b Sun, 14 Dec 2008 16:09:06 +0100 pavan <p>why not use the 'clickCount' prperty of the javafx.scene.input.MouseEvent class</p>