# Copyright 2005, @Last Software, Inc. # This software is provided as an example of using the Ruby interface # to SketchUp. # Permission to use, copy, modify, and distribute this software for # any purpose and without fee is hereby granted, provided that the above # copyright notice appear in all copies. # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #----------------------------------------------------------------------------- require 'sketchup.rb' class ToolTests # Called when you select the tool def activate puts "activate called" end # Called when I select another tool or quit SketchUp def deactivate(view) puts "deactivate called" end # Called when I roll middle mouse button? def draw(view) puts "draw called" end # Called when I roll middle mouse button? # Called when I bring SketchUp into view. Followed directly by draw def getExtents puts "getExtents called" end # This is called followed directly by onRButtonDown def getMenu(menu) puts "getMenu called" end # Called when I press the Esc key. Followed directly by onKeyDown def onCancel(reason, menu) puts "onCancel called" end def onKeyDown(char, rpt, flags, view) puts "onKeyDown called" end def onKeyUp(char, rpt, flags, view) puts "onKeyUp called" end # NOTE: Called after onLButtonDown and onLButtonUp. def onLButtonDoubleClick(flags, x, y, view) puts "onLButtonDoubleClick called" end def onLButtonDown(flags, x, y, view) puts "onLButtonDown called" end def onLButtonUp(flags, x, y, view) puts "onLButtonUp called" end # Called a lot so I did not put a puts message in def onMouseEnter(view) end # Called a lot so I did not put a puts message in def onMouseLeave(view) end # Called a lot so I did not put a puts message in def onMouseMove(flags, x, y, view) end # NOTE: Called after onrButtonDown and onRButtonUp. def onRButtonDoubleClick(flags, x, y, view) puts "onRButtonDoubleClick called" end def onRButtonDown(flags, x, y, view) puts "onRButtonDown called" end # Called not only right after a onRButtonDown, but after a onRButtonDoubleClick? def onRButtonUp(flags, x, y, view) puts "onRButtonUp called" end # NOTE: onReturn is followed directly by onKeyDown def onReturn(view) puts "onReturn called" end def onUserText(text, view) puts "onUserText called" end # Called when I double-click middle mouse button (exits out of orbit) def resume(view) puts "resume called" end # Called when I press middle mouse button (goes into orbit) def suspend(view) puts "suspend called" end end # end of class ToolTests # Add a menu choice for tooltests if( not file_loaded?("tooltests.rb") ) plugins_menu = UI.menu("Plugins") plugins_menu.add_item("ToolTests") { Sketchup.active_model.select_tool ToolTests.new } end