@blakeyrat said:
@RHuckster said:@blakeyrat said:Like the specification for determining which mouse button was pressed during an event.The event object has a button property. Granted it should use constants, but besides that it's no different than C# or Java.It's quite different from C# and (I presume) Java:
@W3C said:
During mouse events caused by the depression or release of a mouse button, button is used to indicate which mouse button changed state. The values for button range from zero to indicate the left button of the mouse, one to indicate the middle button if present, and two to indicate the right button. For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left.So here's how the W3C defines the button property:
@W3C said:
Left = 0
Middle = 1
Right = 2Here's how Microsoft ad-hoc-ed the same property:
@Microsoft said:
None = 0
Left = 1
Right = 2
Left & Right = 3
Middle = 4
Left & Middle = 5
Right & Middle = 6
Left & Right & Middle = 7Tell me: which standard looks like the result of a well-thought-out standards process, and which standard looks like the result of a 3-day cocaine and hot rocks bender?
They both seem like poorly though out solutions that require looked back at the documentation every time you want to change something. IMHO a better design would be to use bitmasks with constants for each button.
function recieveButtonEvent (event) {
if (event.buttons == (LEFT | RIGHT)) alert ('The left and right buttons were both clicked.');
else if (event.buttons
== (MIDDLE | RIGHT)) alert ('The middle and right buttons were both clicked.');
else if (event.buttons == LEFT) alert ('Only the left button was clicked.')
else if (event.buttons & MIDDLE) alert ('The middle button was clicked, and possibly some other buttons');
}