tappatappa Posted August 23, 2013 Share Posted August 23, 2013 Suppose you have to manually implement some sort of "Timeout" Event on a Form.. You have a UniTimer with interval=20000 that must be resetted with each OnMouseMove event. if the mouse does not move, the Application Terminates. What i want is something like this: function window.Onmousemove(sender, x, y, { sender.UniTimer1.reset; } (yeah, I am a ExtJS newbie) I hope this is a simple question, because what I REALLY want is a global Timer, with a global OnMouseMove handler... (and no, the ServerModule.AjaxTimeOut propery is not enough for me) Link to comment Share on other sites More sharing options...
Harry Rogers Posted August 23, 2013 Share Posted August 23, 2013 Hi Nefasto I don't know how to do this but I think it would be a really useful property of a session - perhaps a feature suggestion ? Cheers Link to comment Share on other sites More sharing options...
Oliver Morsch Posted August 23, 2013 Share Posted August 23, 2013 I would use javascript: myTimeout = window.setTimeout(function(){myFunc();}, 20000); // set new timeout (call myFunc() after 20 s) window.clearTimeout(myTimeout); // clear last timeout (before set a new one) Link to comment Share on other sites More sharing options...
tappatappa Posted August 23, 2013 Author Share Posted August 23, 2013 Thank you both for the prompt answers, Oliver and HarryG. So, let's say I define two Events function window.OnAfterrender(sender) { myTimeout = window.setTimeout(function(){myFunc();}, 20000); } function window.Onmousemove(sender, x, y, { sender.clearTimeout(myTimeout); } Two problems: 1) How do I define myFunc? Do I have to add a call to AddJS(...) somewhere in my Delphi/C++ code? 2) myTimeOut is out of scope! Link to comment Share on other sites More sharing options...
Oliver Morsch Posted August 23, 2013 Share Posted August 23, 2013 use TUniForm.script property for a javascript: function myFunc() { alert('do Something after timeout'); } myTimeout = window.setTimeout(function(){myFunc();}, 20000); and in onMouseMove: function window.Onmousemove(sender, x, y, { window.clearTimeout(myTimeout); myTimeout = window.setTimeout(function(){myFunc();}, 20000); } (not tested Link to comment Share on other sites More sharing options...
tappatappa Posted August 23, 2013 Author Share Posted August 23, 2013 Ok I'll give it a try, thank you. Link to comment Share on other sites More sharing options...
Oliver Morsch Posted August 23, 2013 Share Posted August 23, 2013 Now tested: I had forgotten "function" in/before "myFunc()" declaration. I have changed code in #5. It works for me. Link to comment Share on other sites More sharing options...
tappatappa Posted August 26, 2013 Author Share Posted August 26, 2013 I've found a way to implement a global listener of mousemove that resets a TUniTimer. In this example I have a component called "TUniTimer1" in the MainForm. doc=Ext.getDoc(); doc.on('mousemove', function(e) { timer1=MainForm["UniTimer1"]; try{timer1.stopAll()}catch(e){}; task1=timer1.tasks[0]; timer1.cEvent=function(sender) { }; timer1.start(task1); task1.taskRunTime=task1.taskStartTime; }); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now