Creating a new tool

I’m building an extension to draw wide flange steel beams. i’m almost completed with it but stuck on a few small items
I’m wondering if someone can point me in the right direction so i can finish it.

1- How to use the arrow keys as inference locking to red green and blue axes
2- Enhancing the onUserText method to modify the last beam created, if a length is entered after it’s drawn

Are you using InputPoint? If so, then you have View.lock_inference that you can use: http://www.sketchup.com/intl/en/developer/docs/ourdoc/view#lock_inference

Otherwise you have to create your own inference engine.

This is tricky. What I usually do is save the parameters used from last action and in onUserText undo my previous change and recreate the last action with the new input value.
But there are many pitfalls here. You want to make sure you have actually done an operation before - so you don’t inadvertently undo some other random operation. And you might want to listen to the ModelObserver for other transactions might might have been invoked since your last operation and the onUserText event. The user of your tool might have invoked another tool in between which invalidate the model state which your tool assumes.

I am using the view.lock_inference for the onKeyDown method if key == CONSTRAIN_MODIFIER_KEY
but i’d like my tool to use the arrow keys on the keyboard in addition to the shift key

Left-Arrow locks to GREEN from InputPoint
Right-Arrow locks to RED from InputPoint
Up-Arrow locks to BLUE from InputPoint

but i don’t know how to have the onKeyDown check if it is those keys
and is there a way to plug in the Sketchup inference engine? or does each tool have to have it’s own?

Nevermind I got it figured out. i just had to read the onKeyDown documentation