Hello,
About what you mention
Point 1:
Yea you are right, that code was messy, you can just do e.buttons
since it just making sure that that property exists (or in this case that you aren’t pressing a button)
Point 2:
The arguments
object is something that some linter discourage people from using. The linter friendly way of overriding a function would be something like the following
textSelectTool.mouseMove = function (e, ...params) {
origSelect.apply(this,[e, ...params]);
if (!this['pageCoordinates'][1] || !e.buttons !== 1) {
return;
}
}
It’s a bit odd in this cases since "e"
is the only input parameter, so "params"
will end up being an empty array. For overriding functions like this, it safe to use the arguments
object or collecting extra input parameters like the above in case an extra input parameter is added so you can run the original function without errors (won’t happen in this cases since “mouseMove” will only have the event parameter).
Best Regards,
Andrew Yip
Software Developer
PDFTron Systems, Inc.
www.pdftron.com