It’s basically unlocking the inference if the shift key is held down for more than half a second, or unlocking the inference if you press shift again. I can’t explain exactly what the methods are doing without knowing what the @state, @ip, @ip1 instance variables are for.
Agreed. Which is also the same as VK_SHIFT.
Both are 16 on Windows but might differ on Mac so it is safer to use the constants.
CONSTRAIN_MODIFIER_KEY is a SketchUp specific constant name based upon what SketchUp uses the SHIFT key for. Ie, toggling inferences which are usually constraints.
Likewise the VK_CONTROL is usually used for tool “copy mode” and why the API defines the COPY_MODIFIER_KEY constant.
The @state is simply an instance variable used as a counter to keep track of what tool state the tool is in. This looks like code from the "linetool.rb" example and the states would be “ready for first click” (0) and “ready for second click” (1).
The @ip, and @ip1 are Sketchup::InputPoint object references used to help get the points where the user clicks.