src/jwm_draw_framing/draw_framing_main.rb
# onKeyDown is called when the user presses a key on the keyboard.
# We are checking it here to see if the user pressed an arrow key to toggle axis lock on/off 
# so that we can do inference locking
onKeyDown is called when the user presses a key on the keyboard.
We are checking it here to see if the user pressed an arrow key to toggle axis lock on/off
so that we can do inference locking
onKeyDown is called when the user presses a key on the keyboard . We are checking it here to see if the user pressed an arrow key to toggle axis lock on / off so that we can do inference locking
def onKeyDown(key, repeat, flags, view)
  case  key 
  when VK_RIGHT 
    if @@axis_lock == X_AXIS then 
      @@axis_lock = Geom::Vector3d.new 0,0,0
    else
      @@axis_lock = X_AXIS 
    end
  when VK_LEFT 
    if @@axis_lock == Y_AXIS then 
      @@axis_lock = Geom::Vector3d.new 0,0,0
    else
     @@axis_lock = Y_AXIS 
    end
  when VK_UP 
    if @@axis_lock == Z_AXIS then 
      @@axis_lock = Geom::Vector3d.new 0,0,0
    else
      @@axis_lock = Z_AXIS 
    end
  when VK_DOWN  
    if @@axis_lock == Z_AXIS then 
      @@axis_lock = Geom::Vector3d.new 0,0,0
    else
      @@axis_lock = Z_AXIS 
    end
  end
		if key == 9 
		end
		if( key == CONSTRAIN_MODIFIER_KEY && repeat == 1 )
			@shift_down_time = Time.now
			if( view.inference_locked? )
				view.lock_inference
			elsif( @state == 0 && @ip1.valid? )
				view.lock_inference @ip1
				view.line_width = 3
			elsif( @state == 1 && @ip2.valid? )
				view.lock_inference @ip2, @ip1
				view.line_width = 3
			end
		end
		if( key == COPY_MODIFIER_KEY )
		if @state == 0
			txt = "Select start point"
		else
			txt = "Move cursor to set orientation; use arrow keys to toggle axis lock"
		end
		end
		view.refresh
		self.onSetCursor() 
		false 
	end
def onKeyDown ( key , repeat , flags , view ) case key when VK_RIGHT if @@axis_lock == X_AXIS then @@axis_lock = Geom :: Vector3d . new 0 , 0 , 0 else @@axis_lock = X_AXIS end when VK_LEFT if @@axis_lock == Y_AXIS then @@axis_lock = Geom :: Vector3d . new 0 , 0 , 0 else @@axis_lock = Y_AXIS end when VK_UP if @@axis_lock == Z_AXIS then @@axis_lock = Geom :: Vector3d . new 0 , 0 , 0 else @@axis_lock = Z_AXIS end when VK_DOWN if @@axis_lock == Z_AXIS then @@axis_lock = Geom :: Vector3d . new 0 , 0 , 0 else @@axis_lock = Z_AXIS end end if key == 9 end if ( key == CONSTRAIN_MODIFIER_KEY && repeat == 1 ) @shift_down_time = Time . now if ( view . inference_locked? ) view . lock_inference elsif ( @state == 0 && @ip1 . valid? ) view . lock_inference @ip1 view . line_width = 3 elsif ( @state == 1 && @ip2 . valid? ) view . lock_inference @ip2 , @ip1 view . line_width = 3 end end if ( key == COPY_MODIFIER_KEY ) if @state == 0 txt = "Select start point" else txt = "Move cursor to set orientation; use arrow keys to toggle axis lock" end end view . refresh self . onSetCursor ( ) false end
onKeyDown is called when the user presses a key on the keyboard.
onKeyDown is called when the user presses a key on the keyboard .
# Check for Arrow keys to toggle axis lock # Right arrow key pressed: toggle red axis lock on/off # Red axis lock was on: turn all axis locks off # turn red axis lock on # Left arrow key pressed: toggle green axis lock on/off # Axis lock was on: turn all axis locks off # turn green axis lock on # Up  arrow key pressed: toggle blue axis lock on/off # Axis lock was on: turn all axis locks off # turn blue axis lock on # Down arrow key pressed: toggle blue axis lock on/off # Axis lock was on: turn all axis locks off # turn blue axis lock on # puts"Selected axis = " + @@axis_lock.inspect.to_s # Check for Tab key to cycle through orientation of cross section # 9 = Tab  # if n < 5 # n = n + 1 # else  # n=0 # end # view.invalidate # if we already have an inference lock, then unlock it # calling lock_inference with no arguments actually unlocks ###Leftovers from cline_tool #@draw_cpoints = !@draw_cpoints #inc_mode() # if @opts['mode'] == 1# @draw_cpoints # txt << "off." # else # txt << "on." # end #Sketchup::set_status_text(txt, SB_PROMPT) # forces change of cursor on screen # onSetCursor # need to do something after onSetCursor # TT - The culprit is onSetCursor when it's called last in onKey or onLButton events. 
key
<not_specific>
repeat
<not_specific>
flags
<not_specific>
view
<not_specific>