• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 623
  • Last Modified:

Javascript Dynamic Function Creation For onmousemove event

Basically the jist of the question is this.  I have multiple function that I need to be running during the onmousemove event for different purposes.  They cannot be combined into a single function.  I've attempted a few things, but most of them end up just not working, they don't throw an error, but they don't work either.  Here's a quick example of some of the things I've tried:

function func1(e)
{
      grabMouseLocation();
}

function func2(e)
{
      updateDisplayProperties();
}
//assume the two referenced function exist.
//these are thing things I've tried.
// 1
document.onmousemove = func1 + func2;
// 2
document.onmousemove = eval(func1 + func2);
// 3
document.onmousemove = eval(func1 + ";" + func2 + ";");

I'm out of ideas at this point. I've basically come to the conclusion that using a string or and evaluation thereof won't work.  Any help would be much appreciated!! Thanks!!

0
skacore
Asked:
skacore
  • 3
1 Solution
 
ZvonkoSystems architectCommented:
Check this:

document.onmousemove = function(e){
    func1(e);
    func1(e);
}

0
 
ZvonkoSystems architectCommented:
And you tried all three times to concationate the String representations of both function referencies.

0
 
Pravin AsarCommented:
Normally when you have two or more function calls , second and/or subsequent ones are dependent on others,

In such case do

function func1(e)
{
     grabMouseLocation();
}

function func2(e)
{
     updateDisplayProperties();
}
function funcWrapper (e) {
   if (func1(e)) {
           func2(e);
   }
}

document.onmousemove = funcWrapper ;
0
 
ZvonkoSystems architectCommented:
And there is no limit to make things more complicated, does say, you can wrap the wrapper ;-)

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now