User Tools

Site Tools


script_double_click

====== About the script ====== * Purpose : This is a script to allow custom tap/double tap * Author : [[https://plus.google.com/u/1/105066926163073195690|TrianguloY]] * Link: https://plus.google.com/u/1/105066926163073195690/posts/3EmnQshjVr9 ====== How to use the script ====== Instructions: Set the script in an event of the items you want. You may want to set it in the tap action, but nobody says you can't set it in a swipe or something else. By default it will launch the item when single tap, and go to the main desktop when double tap. But of course you can (and may) change them to what you want, you will need to know scripting to do so. With widgets it works ok, but the widget always get executed when tap, and perform the launch action will send a error. You can use this for example to do nothing when tap, and something when double tap (even thought the widget will get both clicks! ) ====== Script code ====== <sxh javascript> //time in milliseconds between clicks var delta = 250; function singletap(){ //action to execute in single tap item.launch(); } function doubletap(){ //action to execute in double tap LL.goToDesktop(LL.getHomeDesktop().getId()); } var event=LL.getEvent(); var item=event.getItem(); var id=item.getId(); var time=event.getDate(); var data = JSON.parse(LL.getScriptTag())||[-1,-1]; if(data[0]==id && time < ( data[1] + delta) ){ LL.setScriptTag(null); doubletap(); }else{ LL.setScriptTag(JSON.stringify([id,time])); setTimeout(function(){data2=JSON.parse(LL.getScriptTag())||[-1,-1];if(data2[0]==id&&data2[1]==time)singletap();},delta); } </sxh>

script_double_click.txt · Last modified: 2014/07/22 14:45 by trianguloy