lewisje / ourlibrary

Automatically exported from code.google.com/p/ourlibrary
0 stars 0 forks source link

ondrag callback must return true to cancel the dragging #9

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
At line #4008, the - callback - function returns this:
   return !ondrag || !callInContext(ondrag, callbackContext, c, co);

Which would cause this function to return true if the - ondrag - callback
returns false. I'm guessing that the desired behavior is the opposite.

So, the correct return might be
   return !ondrag || callInContext(ondrag, callbackContext, c, co);

Patched partial build attached.

Original issue reported on code.google.com by gabrielg...@gmail.com on 30 Mar 2010 at 3:12

Attachments:

GoogleCodeExporter commented 9 years ago
No, as odd as it may seem, returning something "truthy" is how you cancel the 
default behavior.  This is consistent with other API and add-on callbacks.  
These 
aren't listeners, so I didn't feel I needed to follow listener conventions.  
The 
default behavior follows through if you return nothing (or false of course).  
Think 
of the return value for callbacks as indicating that your code has handled the 
situation on its own or not (as opposed to whether it wants to cancel or not).

It is early enough in the game to change it (and there aren't a lot of places 
that 
have such callbacks), but I think documenting the callback interface will clear 
up 
any confusion.  I'm open to suggestions though.

Original comment by dmark.ci...@gmail.com on 30 Mar 2010 at 4:39

GoogleCodeExporter commented 9 years ago
Hm, I see. It sounds counter-intuitive to me, and I'm guessing that it will for 
most
of the newcomers. The main reason is exactly how DOM0 listeners handle it, I 
think
that following their conventions would be the less surprising behavior at first 
glance.

Original comment by gabrielg...@gmail.com on 30 Mar 2010 at 4:48

GoogleCodeExporter commented 9 years ago
Yes, the return true convention for callback behavior overriding the default is 
something I've used since back in my days as a Windows application developer 
(where 
such practice was more prevalent), but I agree that it would be better to 
switch it 
for the release.  I'll have to review where I am doing this (alert add-on comes 
to 
mind) and I don't think it is in a lot of places.

Original comment by dmark.ci...@gmail.com on 30 Mar 2010 at 5:09

GoogleCodeExporter commented 9 years ago
For now I'll use the current convention then.
Thanks, David.

Original comment by gabrielg...@gmail.com on 30 Mar 2010 at 5:26

GoogleCodeExporter commented 9 years ago

Original comment by dmark.ci...@gmail.com on 30 Mar 2010 at 5:53

GoogleCodeExporter commented 9 years ago

Original comment by dmark.ci...@gmail.com on 13 May 2010 at 9:41