Page 4 of 4 FirstFirst ... 234
Results 31 to 34 of 34

Thread: Checking if mouse is moving or not

  1. #31
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Hmm, perhaps:
    Code:
    el['on' + ev] = function() {
      return a.apply(this, arguments)
        && f.apply(this, arguments);
    };
    Thus, if one returns false nothing else happens.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  2. #32
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey View Post
    Hmm, perhaps:
    Code:
    el['on' + ev] = function() {
      return a.apply(this, arguments)
        && f.apply(this, arguments);
    };
    Thus, if one returns false nothing else happens.
    That could work or it could get dicey, literally. It might be a matter of chance at that point. Testing is required. In IE you should, I think, be able to do:

    Code:
    el['on' + ev] = function() {
      a.apply(this, arguments)
      f.apply(this, arguments);
    if (a.returnValue===false || f.returnValue===false)
    return false;
    };
    If your idea doesn't pan out and there is no other universal solution of some sort, it is just a matter of the designer being aware and setting things up as required in any given situation.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #33
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    <aside>
    Quote Originally Posted by Twey View Post
    Quote Originally Posted by jscheuer1
    Is that ++i a Brit thing?
    Nope, it's a Mike thing originally Apparently it's more efficient in certain old compilers, ...
    In C++ (and possibly other languages with similar mechanics), the post-increment and -decrement operators create a temporary object which is the result of the expression when evaluated. The pre-increment and -decrement operators do not as it's the altered value that's used for the result.

    As for "old compilers", I'm not sure if that applies: it may be necessary to construct the temporary object so that all side-effects can occur, even if the temporary object itself is immediately destroyed after evaluation of the (expression) statement.
    </aside>

    Quote Originally Posted by Twey View Post
    Hmm, perhaps:
    Code:
    el['on' + ev] = function() {
      return a.apply(this, arguments)
        && f.apply(this, arguments);
    };
    Thus, if one returns false nothing else happens.
    That isn't desirable: even the stopPropagation method is supposed to allow all listeners to complete before stopping event propagation. Instead, use:

    Code:
    el['on' + ev] = function () {
        var result = a.apply(this, arguments);
        return f.apply(this, arguments) && result;
    };
    Mike

  4. #34
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    if (a.returnValue===false || f.returnValue===false)
    No, this wouldn't happen... the functions would set the return value on event:
    Code:
    el['on' + ev] = function() {
      a.apply(this, arguments)
      a.returnValue = arguments[0].returnValue;
      f.apply(this, arguments);
      f.returnValue = arguments[0].returnValue;
      return a.returnValue && f.returnValue;
    };
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •