sketchup-api-stubs 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.yardopts +9 -9
- data/lib/sketchup-api-stubs.rb +1 -1
- data/lib/sketchup-api-stubs/sketchup.rb +145 -145
- data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +318 -318
- data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +172 -172
- data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +126 -126
- data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +102 -102
- data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +400 -400
- data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +661 -661
- data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +492 -492
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +478 -478
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +263 -263
- data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +141 -141
- data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +522 -522
- data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +691 -691
- data/lib/sketchup-api-stubs/stubs/Layout.rb +25 -25
- data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +573 -573
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +411 -411
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +174 -186
- data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
- data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +514 -514
- data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
- data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +143 -155
- data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +349 -349
- data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +311 -311
- data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +261 -261
- data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +91 -91
- data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +371 -371
- data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +218 -218
- data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +128 -128
- data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +220 -232
- data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +567 -567
- data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +10 -10
- data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +11 -11
- data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +183 -183
- data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +387 -387
- data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +204 -216
- data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +344 -344
- data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +174 -174
- data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +694 -694
- data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1519 -1519
- data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +290 -290
- data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +139 -139
- data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +135 -135
- data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +140 -140
- data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +157 -157
- data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +209 -209
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +152 -152
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +281 -281
- data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +328 -328
- data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +577 -577
- data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
- data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +122 -122
- data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +281 -281
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +562 -562
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +593 -593
- data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +76 -76
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +257 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +32 -32
- data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +194 -194
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +329 -329
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +72 -72
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +102 -102
- data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +165 -165
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +312 -312
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +38 -38
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
- data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +390 -390
- data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +508 -508
- data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1119 -1119
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +125 -125
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +544 -544
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +59 -59
- data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +125 -125
- data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +750 -750
- data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +104 -104
- data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +697 -697
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +285 -285
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +62 -62
- data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +409 -409
- data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +226 -226
- data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +190 -190
- data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +393 -393
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +82 -82
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +303 -303
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +285 -280
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +244 -231
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +136 -136
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +48 -48
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +112 -123
- data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
- data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +416 -416
- data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +311 -311
- data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +141 -141
- data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +95 -95
- data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1638 -1601
- data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +356 -356
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +132 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +284 -284
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
- data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +770 -770
- data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +76 -76
- data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +456 -456
- data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +364 -364
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +44 -44
- data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
- data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +454 -454
- data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +115 -115
- data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +212 -212
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +257 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +57 -57
- data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +69 -69
- data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +211 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +262 -262
- data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +225 -225
- data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +829 -829
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +154 -154
- data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +61 -61
- data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +142 -142
- data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1301 -1301
- data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +43 -43
- data/lib/sketchup-api-stubs/stubs/UI/Command.rb +310 -310
- data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +356 -356
- data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +229 -229
- data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +240 -240
- data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +633 -633
- data/lib/sketchup-api-stubs/stubs/_top_level.rb +311 -311
- data/lib/sketchup-api-stubs/stubs/array.rb +741 -741
- data/lib/sketchup-api-stubs/stubs/geom.rb +348 -348
- data/lib/sketchup-api-stubs/stubs/languagehandler.rb +92 -92
- data/lib/sketchup-api-stubs/stubs/length.rb +278 -278
- data/lib/sketchup-api-stubs/stubs/numeric.rb +249 -249
- data/lib/sketchup-api-stubs/stubs/sketchup.rb +1310 -1310
- data/lib/sketchup-api-stubs/stubs/sketchupextension.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/string.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/ui.rb +667 -667
- metadata +3 -4
@@ -1,829 +1,829 @@
|
|
1
|
-
# Copyright:: Copyright 2020 Trimble Inc.
|
2
|
-
# License:: The MIT License (MIT)
|
3
|
-
|
4
|
-
# Tool is the interface that you implement to create a SketchUp tool.
|
5
|
-
# See https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/master/examples/02_custom_tool
|
6
|
-
# for an example of how to create a custom tool in Ruby.
|
7
|
-
#
|
8
|
-
# To create a new tool in Ruby, you must define a new class that implements
|
9
|
-
# the methods for the events that you want to respond to. You do not have
|
10
|
-
# to implement methods for every possible event that a Tool can respond to.
|
11
|
-
#
|
12
|
-
# Once you have defined a tool class, you select that tool by creating an
|
13
|
-
# instance of it and passing it to {Sketchup::Model#select_tool}. For
|
14
|
-
# example:
|
15
|
-
#
|
16
|
-
# class MyTool
|
17
|
-
# def activate
|
18
|
-
# puts 'Your tool has been activated.'
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# my_tool = MyTool.new
|
23
|
-
# Sketchup.active_model.select_tool(my_tool)
|
24
|
-
#
|
25
|
-
# The following table contains several constants you can use when check for
|
26
|
-
# certain key presses inside the keyboard handling callbacks:
|
27
|
-
#
|
28
|
-
# - +CONSTRAIN_MODIFIER_KEY+ = Shift Key
|
29
|
-
# - +CONSTRAIN_MODIFIER_MASK+ = Shift Key
|
30
|
-
# - +COPY_MODIFIER_KEY+ = Alt/Option on Mac, Ctrl on PC
|
31
|
-
# - +COPY_MODIFIER_MASK+ = Alt/Option on Mac, Ctrl on PC
|
32
|
-
# - +ALT_MODIFIER_KEY+ = Command on Mac, Alt on PC
|
33
|
-
# - +ALT_MODIFIER_MASK+ = Command on Mac, Alt on PC
|
34
|
-
#
|
35
|
-
# @version SketchUp 6.0
|
36
|
-
class Sketchup::Tool
|
37
|
-
|
38
|
-
# Instance Methods
|
39
|
-
|
40
|
-
# The #{activate} method is called by SketchUp when the tool is selected.
|
41
|
-
# It is a good place to put most of your initialization, such as instance
|
42
|
-
# variables to track the state of the tool.
|
43
|
-
#
|
44
|
-
# @example
|
45
|
-
# def activate
|
46
|
-
# puts 'Your tool has been activated.'
|
47
|
-
# end
|
48
|
-
#
|
49
|
-
# @version SketchUp 6.0
|
50
|
-
def activate
|
51
|
-
end
|
52
|
-
|
53
|
-
# The #{deactivate} method is called when the tool is deactivated because a
|
54
|
-
# different tool was selected.
|
55
|
-
#
|
56
|
-
# @example
|
57
|
-
# def deactivate(view)
|
58
|
-
# puts "Your tool has been deactivated in view: #{view}"
|
59
|
-
# end
|
60
|
-
#
|
61
|
-
# @param [Sketchup::View] view
|
62
|
-
#
|
63
|
-
# @version SketchUp 6.0
|
64
|
-
def deactivate(view)
|
65
|
-
end
|
66
|
-
|
67
|
-
# The {#draw} method is called by SketchUp whenever the view is refreshed to
|
68
|
-
# allow the tool to do its own drawing. If the tool has some temporary graphics
|
69
|
-
# that it wants displayed while it is active, it should implement this method
|
70
|
-
# and draw to the {Sketchup::View}.
|
71
|
-
#
|
72
|
-
# @example
|
73
|
-
# def draw(view)
|
74
|
-
# # Draw a square.
|
75
|
-
# points = [
|
76
|
-
# Geom::Point3d.new(0, 0, 0),
|
77
|
-
# Geom::Point3d.new(9, 0, 0),
|
78
|
-
# Geom::Point3d.new(9, 9, 0),
|
79
|
-
# Geom::Point3d.new(0, 9, 0)
|
80
|
-
# ]
|
81
|
-
# # Fill
|
82
|
-
# view.drawing_color = Sketchup::Color.new(255, 128, 128)
|
83
|
-
# view.draw(GL_QUADS, points)
|
84
|
-
# # Outline
|
85
|
-
# view.line_stipple = '' # Solid line
|
86
|
-
# view.drawing_color = Sketchup::Color.new(64, 0, 0)
|
87
|
-
# view.draw(GL_LINE_LOOP, points)
|
88
|
-
# end
|
89
|
-
#
|
90
|
-
# @note If you draw outside the model bounds you need to implement
|
91
|
-
# {Tool#getExtents} which return a bounding box large enough to include the
|
92
|
-
# points you draw. Otherwise your drawing will be clipped.
|
93
|
-
#
|
94
|
-
# @param [Sketchup::View] view
|
95
|
-
# A View object where the method was invoked.
|
96
|
-
#
|
97
|
-
# @see getExtents
|
98
|
-
#
|
99
|
-
# @see Sketchup::View#draw
|
100
|
-
#
|
101
|
-
# @version SketchUp 6.0
|
102
|
-
def draw(view)
|
103
|
-
end
|
104
|
-
|
105
|
-
# The #{enableVCB?} method is used to tell SketchUp whether to allow the user
|
106
|
-
# to enter text into the VCB (value control box, aka the "measurements" panel).
|
107
|
-
# If you do not implement this method, then the vcb is disabled by default.
|
108
|
-
#
|
109
|
-
# @example
|
110
|
-
# # For this tool, allow vcb text entry while the tool is active.
|
111
|
-
# def enableVCB?
|
112
|
-
# return true
|
113
|
-
# end
|
114
|
-
#
|
115
|
-
# @return [Boolean] Return +true+ if you want the VCB enabled
|
116
|
-
#
|
117
|
-
# @version SketchUp 6.0
|
118
|
-
def enableVCB?
|
119
|
-
end
|
120
|
-
|
121
|
-
# In order to accurately draw things, SketchUp needs to know the extents of
|
122
|
-
# what it is drawing. If the tool is doing its own drawing, it may need to
|
123
|
-
# implement this method to tell SketchUp the extents of what it will be
|
124
|
-
# drawing. If you don't implement this method, you may find that part of what
|
125
|
-
# the tool is drawing gets clipped to the extents of the rest of the
|
126
|
-
# model.
|
127
|
-
#
|
128
|
-
# This must return a {Geom::BoundingBox}. In a typical implementation, you
|
129
|
-
# will create a new {Geom::BoundingBox}, add points to set the extents of the
|
130
|
-
# drawing that the tool will do and then return it.
|
131
|
-
#
|
132
|
-
# @example
|
133
|
-
# def getExtents
|
134
|
-
# bb = Sketchup.active_model.bounds
|
135
|
-
# return bb
|
136
|
-
# end
|
137
|
-
#
|
138
|
-
# @return [Geom::BoundingBox]
|
139
|
-
#
|
140
|
-
# @version SketchUp 6.0
|
141
|
-
def getExtents
|
142
|
-
end
|
143
|
-
|
144
|
-
# The #{getInstructorContentDirectory} method is used to tell SketchUp the
|
145
|
-
# directory containing your Tool's instructor content. To use this, create
|
146
|
-
# a custom instructor directory, put an index.html file inside of it, and then
|
147
|
-
# return that path via this method. If the SketchUp user has the Instructor
|
148
|
-
# window open when they activate your tool, they will see your html file.
|
149
|
-
#
|
150
|
-
# @example
|
151
|
-
# def getInstructorContentDirectory
|
152
|
-
# extension_path = Sketchup.extensions['MyExtension].extension_path
|
153
|
-
# instructor_path = File.join(extension_path, 'MyExtension', 'instructor')
|
154
|
-
# return instructor_path
|
155
|
-
# end
|
156
|
-
#
|
157
|
-
# @note Prior to SketchUp 2014 this method would assume the path was relative
|
158
|
-
# to the SketchUp resource folder. From 2014 and onwards you can specify the
|
159
|
-
# absolute path to an HTML file or the absolute path to a directory
|
160
|
-
# containing an index.html file.
|
161
|
-
#
|
162
|
-
# @return [String] the directory path where the Instructor content exists.
|
163
|
-
#
|
164
|
-
# @version SketchUp 6.0
|
165
|
-
def getInstructorContentDirectory
|
166
|
-
end
|
167
|
-
|
168
|
-
# The #{getMenu} method is called by SketchUp to let the tool provide its own
|
169
|
-
# context menu. Most tools will not want to implement this method and,
|
170
|
-
# instead, use the normal context menu found on all entities.
|
171
|
-
#
|
172
|
-
# If you do implement this method, the argument is a Menu. You should use the
|
173
|
-
# add_item method to build the context menu.
|
174
|
-
#
|
175
|
-
# Your tool will use a standard context menu by default if you do not
|
176
|
-
# implement this method. Implement this method if you want a context-click to
|
177
|
-
# display something other than this default context menu.
|
178
|
-
#
|
179
|
-
# In SketchUp 2015 the flags, x, y and view parameters were added. They are
|
180
|
-
# needed if you need to pick the entities under the mouse position. The new
|
181
|
-
# parameters are optional, but if you need to use one you must include them
|
182
|
-
# all.
|
183
|
-
#
|
184
|
-
# @example
|
185
|
-
# if Sketchup.version.to_i < 15
|
186
|
-
# # Compatible with SketchUp 2014 and older:
|
187
|
-
# def getMenu(menu)
|
188
|
-
# menu.add_item('Say Hello') {
|
189
|
-
# UI.messagebox('Hello')
|
190
|
-
# }
|
191
|
-
# end
|
192
|
-
# else
|
193
|
-
# # Only works with SketchUp 2015 and newer:
|
194
|
-
# def getMenu(menu, flags, x, y, view)
|
195
|
-
# ph = view.pick_helper(x, y)
|
196
|
-
# entity = ph.best_picked
|
197
|
-
# if entity
|
198
|
-
# view.model.selection.clear
|
199
|
-
# view.model.selection.add(entity)
|
200
|
-
# menu.add_item("Erase #{entity.typename}") {
|
201
|
-
# entity.erase!
|
202
|
-
# }
|
203
|
-
# end
|
204
|
-
# end
|
205
|
-
# end
|
206
|
-
#
|
207
|
-
# @param menu
|
208
|
-
# A Menu object.
|
209
|
-
#
|
210
|
-
# @param [optional] flags
|
211
|
-
# A bit mask that tells the state of the
|
212
|
-
# modifier keys and other mouse buttons at the time.
|
213
|
-
# Added in SU2015.
|
214
|
-
#
|
215
|
-
# @param [optional] x
|
216
|
-
# The X coordinate on the screen where the
|
217
|
-
# event occurred. Added in SU2015.
|
218
|
-
#
|
219
|
-
# @param [optional] y
|
220
|
-
# The Y coordinate on the screen where the
|
221
|
-
# event occurred. Added in SU2015.
|
222
|
-
#
|
223
|
-
# @param [optional] view
|
224
|
-
# A View object where the method was invoked.
|
225
|
-
# Added in SU2015.
|
226
|
-
#
|
227
|
-
# @return nil
|
228
|
-
#
|
229
|
-
# @version SketchUp 6.0
|
230
|
-
def getMenu(menu, flags, x, y, view)
|
231
|
-
end
|
232
|
-
|
233
|
-
# The {#onCancel} method is called by SketchUp to cancel the current operation
|
234
|
-
# of the tool. The typical response will be to reset the tool to its initial
|
235
|
-
# state.
|
236
|
-
#
|
237
|
-
# The reason identifies the action that triggered the call. The reason can be
|
238
|
-
# one of the following values:
|
239
|
-
#
|
240
|
-
# - +0+: the user canceled the current operation by hitting the escape key.
|
241
|
-
# - +1+: the user re-selected the same tool from the toolbar or menu.
|
242
|
-
# - +2+: the user did an undo while the tool was active.
|
243
|
-
#
|
244
|
-
# @example
|
245
|
-
# def onCancel(reason, view)
|
246
|
-
# puts "MyTool was canceled for reason ##{reason} in view: #{view}"
|
247
|
-
# end
|
248
|
-
#
|
249
|
-
# @note When something is undone {#onCancel} is called before the undo is
|
250
|
-
# actually executed. If you need to do something with the model after an undo
|
251
|
-
# use {Sketchup::ModelObserver#onTransactionUndo}.
|
252
|
-
#
|
253
|
-
# @param [Integer] reason
|
254
|
-
# A reason value (see comments).
|
255
|
-
#
|
256
|
-
# @param [Sketchup::View] view
|
257
|
-
#
|
258
|
-
# @version SketchUp 6.0
|
259
|
-
def onCancel(reason, view)
|
260
|
-
end
|
261
|
-
|
262
|
-
# The #{onKeyDown} method is called by SketchUp when the user presses a key on
|
263
|
-
# the keyboard. If you want to get input from the VCB, you should implement
|
264
|
-
# onUserText rather than this method.
|
265
|
-
#
|
266
|
-
# This method is can be used for special keys such as the Shift key, Ctrl key,
|
267
|
-
# and so on, or for just determining which key a user pressed. This method is
|
268
|
-
# actually called for all keys that are pressed.
|
269
|
-
#
|
270
|
-
# There are several
|
271
|
-
# "virtual keys" defined as constants you can use. Their use is cross
|
272
|
-
# platform. They are:
|
273
|
-
#
|
274
|
-
# - +VK_ALT+
|
275
|
-
# - +VK_COMMAND+
|
276
|
-
# - +VK_CONTROL+
|
277
|
-
# - +VK_DELETE+
|
278
|
-
# - +VK_DOWN+
|
279
|
-
# - +VK_END+
|
280
|
-
# - +VK_HOME+
|
281
|
-
# - +VK_INSERT+
|
282
|
-
# - +VK_LEFT+
|
283
|
-
# - +VK_MENU+
|
284
|
-
# - +VK_NEXT+
|
285
|
-
# - +VK_PRIOR+
|
286
|
-
# - +VK_RIGHT+
|
287
|
-
# - +VK_SHIFT+
|
288
|
-
# - +VK_SPACE+
|
289
|
-
# - +VK_UP+
|
290
|
-
#
|
291
|
-
# V6: There is a bug on Windows where the typematic effect does
|
292
|
-
# not work. Typematic effects work fine on a Mac.
|
293
|
-
#
|
294
|
-
# @example
|
295
|
-
# def onKeyDown(key, repeat, flags, view)
|
296
|
-
# puts "onKeyDown: key = #{key}"
|
297
|
-
# puts " repeat = #{repeat}"
|
298
|
-
# puts " flags = #{flags}"
|
299
|
-
# puts " view = #{view}"
|
300
|
-
# end
|
301
|
-
#
|
302
|
-
# @param [Integer] key
|
303
|
-
# The key that was pressed.
|
304
|
-
#
|
305
|
-
# @param [Integer] repeat
|
306
|
-
# A value of 1 for a single press of a key. A value
|
307
|
-
# of 2 if the user has pressed a key and is holding
|
308
|
-
# it down.
|
309
|
-
#
|
310
|
-
# @param [Integer] flags
|
311
|
-
# A bit mask that tells the state of the modifier
|
312
|
-
# keys at the time of the event.
|
313
|
-
#
|
314
|
-
# @param [Sketchup::View] view
|
315
|
-
#
|
316
|
-
# @return [Boolean] Return +true+ to prevent SketchUp from processing the
|
317
|
-
# event.
|
318
|
-
#
|
319
|
-
# @version SketchUp 6.0
|
320
|
-
def onKeyDown(key, repeat, flags, view)
|
321
|
-
end
|
322
|
-
|
323
|
-
# The #{onKeyUp} method is called by SketchUp when the user releases a key on
|
324
|
-
# the keyboard.
|
325
|
-
#
|
326
|
-
# @example
|
327
|
-
# def onKeyUp(key, repeat, flags, view)
|
328
|
-
# puts "onKeyUp: key = #{key}"
|
329
|
-
# puts " repeat = #{repeat}"
|
330
|
-
# puts " flags = #{flags}"
|
331
|
-
# puts " view = #{view}"
|
332
|
-
# end
|
333
|
-
#
|
334
|
-
# @param [Integer] key
|
335
|
-
# The key that was pressed.
|
336
|
-
#
|
337
|
-
# @param [Integer] repeat
|
338
|
-
# A value of 1 for a single press of a key. A value
|
339
|
-
# of 2 if the user has pressed a key and is holding
|
340
|
-
# it down.
|
341
|
-
#
|
342
|
-
# @param [Integer] flags
|
343
|
-
# A bit mask that tells the state of the modifier
|
344
|
-
# keys at the time of the event.
|
345
|
-
#
|
346
|
-
# @param [Sketchup::View] view
|
347
|
-
#
|
348
|
-
# @return [Boolean] Return +true+ to prevent SketchUp from processing the
|
349
|
-
# event.
|
350
|
-
#
|
351
|
-
# @version SketchUp 6.0
|
352
|
-
def onKeyUp(key, repeat, flags, view)
|
353
|
-
end
|
354
|
-
|
355
|
-
# The #{onLButtonDoubleClick} is called by SketchUp when the user double clicks
|
356
|
-
# with the left mouse button.
|
357
|
-
#
|
358
|
-
# @example
|
359
|
-
# def onLButtonDoubleClick(flags, x, y, view)
|
360
|
-
# puts "onLButtonDoubleClick: flags = #{flags}"
|
361
|
-
# puts " x = #{x}"
|
362
|
-
# puts " y = #{y}"
|
363
|
-
# puts " view = #{view}"
|
364
|
-
# end
|
365
|
-
#
|
366
|
-
# @param [Integer] flags
|
367
|
-
# A bit mask that tells the state of the modifier
|
368
|
-
# keys and other mouse buttons at the time.
|
369
|
-
#
|
370
|
-
# @param [Integer] x
|
371
|
-
# The X coordinate on the screen where the event occurred.
|
372
|
-
#
|
373
|
-
# @param [Integer] y
|
374
|
-
# The Y coordinate on the screen where the event occurred.
|
375
|
-
#
|
376
|
-
# @param [Sketchup::View] view
|
377
|
-
#
|
378
|
-
# @version SketchUp 6.0
|
379
|
-
def onLButtonDoubleClick(flags, x, y, view)
|
380
|
-
end
|
381
|
-
|
382
|
-
# The #{onLButtonDown} method is called by SketchUp when the left mouse button
|
383
|
-
# is pressed. Most tools will implement this method.
|
384
|
-
#
|
385
|
-
# @example
|
386
|
-
# def onLButtonDown(flags, x, y, view)
|
387
|
-
# puts "onLButtonDown: flags = #{flags}"
|
388
|
-
# puts " x = #{x}"
|
389
|
-
# puts " y = #{y}"
|
390
|
-
# puts " view = #{view}"
|
391
|
-
# end
|
392
|
-
#
|
393
|
-
# @param [Integer] flags
|
394
|
-
# A bit mask that tells the state of the modifier
|
395
|
-
# keys and other mouse buttons at the time.
|
396
|
-
#
|
397
|
-
# @param [Integer] x
|
398
|
-
# The X coordinate on the screen where the event occurred.
|
399
|
-
#
|
400
|
-
# @param [Integer] y
|
401
|
-
# The Y coordinate on the screen where the event occurred.
|
402
|
-
#
|
403
|
-
# @param [Sketchup::View] view
|
404
|
-
#
|
405
|
-
# @version SketchUp 6.0
|
406
|
-
def onLButtonDown(flags, x, y, view)
|
407
|
-
end
|
408
|
-
|
409
|
-
# The #{onLButtonUp} method is called by SketchUp when the left mouse button is
|
410
|
-
# released.
|
411
|
-
#
|
412
|
-
# @example
|
413
|
-
# def onLButtonUp(flags, x, y, view)
|
414
|
-
# puts "onLButtonUp: flags = #{flags}"
|
415
|
-
# puts " x = #{x}"
|
416
|
-
# puts " y = #{y}"
|
417
|
-
# puts " view = #{view}"
|
418
|
-
# end
|
419
|
-
#
|
420
|
-
# @param [Integer] flags
|
421
|
-
# A bit mask that tells the state of the modifier
|
422
|
-
# keys and other mouse buttons at the time.
|
423
|
-
#
|
424
|
-
# @param [Integer] x
|
425
|
-
# The X coordinate on the screen where the event occurred.
|
426
|
-
#
|
427
|
-
# @param [Integer] y
|
428
|
-
# The Y coordinate on the screen where the event occurred.
|
429
|
-
#
|
430
|
-
# @param [Sketchup::View] view
|
431
|
-
#
|
432
|
-
# @version SketchUp 6.0
|
433
|
-
def onLButtonUp(flags, x, y, view)
|
434
|
-
end
|
435
|
-
|
436
|
-
# The #{onMButtonDoubleClick} method is called by SketchUp when the middle
|
437
|
-
# mouse button (on a three button mouse) is double-clicked.
|
438
|
-
#
|
439
|
-
# Only implement this method if you want SketchUp to react to a middle mouse
|
440
|
-
# button being double-clicked.
|
441
|
-
#
|
442
|
-
# @example
|
443
|
-
# def onMButtonDoubleClick(flags, x, y, view)
|
444
|
-
# puts "onMButtonDoubleClick: flags = #{flags}"
|
445
|
-
# puts " x = #{x}"
|
446
|
-
# puts " y = #{y}"
|
447
|
-
# puts " view = #{view}"
|
448
|
-
# end
|
449
|
-
#
|
450
|
-
# @note Though this method has been documented in the Ruby API for many years,
|
451
|
-
# it has never worked properly. We are leaving this documentation in place
|
452
|
-
# for now in the hopes of fixing the implementation, but you won't have any
|
453
|
-
# luck trying to use it in SU7 and earlier.
|
454
|
-
#
|
455
|
-
# @param [Integer] flags
|
456
|
-
# A bit mask that tells the state of the modifier
|
457
|
-
# keys and other mouse buttons at the time.
|
458
|
-
#
|
459
|
-
# @param [Integer] x
|
460
|
-
# The X coordinate on the screen where the event occurred.
|
461
|
-
#
|
462
|
-
# @param [Integer] y
|
463
|
-
# The Y coordinate on the screen where the event occurred.
|
464
|
-
#
|
465
|
-
# @param [Sketchup::View] view
|
466
|
-
#
|
467
|
-
# @version SketchUp 6.0
|
468
|
-
def onMButtonDoubleClick(flags, x, y, view)
|
469
|
-
end
|
470
|
-
|
471
|
-
# The #{onMButtonDown} method is called by SketchUp when the middle mouse
|
472
|
-
# button (on a three button mouse) is down.
|
473
|
-
#
|
474
|
-
# The Orbit tool is activated by default when the middle mouse button is down.
|
475
|
-
# Implement this method if you want a middle mouse button to do something
|
476
|
-
# other than invoke the Orbit tool.
|
477
|
-
#
|
478
|
-
# @example
|
479
|
-
# def onMButtonDown(flags, x, y, view)
|
480
|
-
# puts "onMButtonDown: flags = #{flags}"
|
481
|
-
# puts " x = #{x}"
|
482
|
-
# puts " y = #{y}"
|
483
|
-
# puts " view = #{view}"
|
484
|
-
# end
|
485
|
-
#
|
486
|
-
# @param [Integer] flags
|
487
|
-
# A bit mask that tells the state of the modifier
|
488
|
-
# keys and other mouse buttons at the time.
|
489
|
-
#
|
490
|
-
# @param [Integer] x
|
491
|
-
# The X coordinate on the screen where the event occurred.
|
492
|
-
#
|
493
|
-
# @param [Integer] y
|
494
|
-
# The Y coordinate on the screen where the event occurred.
|
495
|
-
#
|
496
|
-
# @param [Sketchup::View] view
|
497
|
-
#
|
498
|
-
# @version SketchUp 6.0
|
499
|
-
def onMButtonDown(flags, x, y, view)
|
500
|
-
end
|
501
|
-
|
502
|
-
# The #{onMButtonUp} method is called by SketchUp when the middle mouse button
|
503
|
-
# (on a three button mouse) is released.
|
504
|
-
#
|
505
|
-
# SketchUp returns to the previous tool from the Orbit tool when the middle
|
506
|
-
# mouse button is released. Implement this method if you want a middle mouse
|
507
|
-
# button to do something other than return to the previous tool when in the
|
508
|
-
# Orbit tool.
|
509
|
-
#
|
510
|
-
# @example
|
511
|
-
# def onMButtonUp(flags, x, y, view)
|
512
|
-
# puts "onMButtonUp: flags = #{flags}"
|
513
|
-
# puts " x = #{x}"
|
514
|
-
# puts " y = #{y}"
|
515
|
-
# puts " view = #{view}"
|
516
|
-
# end
|
517
|
-
#
|
518
|
-
# @param [Integer] flags
|
519
|
-
# A bit mask that tells the state of the modifier
|
520
|
-
# keys and other mouse buttons at the time.
|
521
|
-
#
|
522
|
-
# @param [Integer] x
|
523
|
-
# The X coordinate on the screen where the event occurred.
|
524
|
-
#
|
525
|
-
# @param [Integer] y
|
526
|
-
# The Y coordinate on the screen where the event occurred.
|
527
|
-
#
|
528
|
-
# @param [Sketchup::View] view
|
529
|
-
#
|
530
|
-
# @version SketchUp 6.0
|
531
|
-
def onMButtonUp(flags, x, y, view)
|
532
|
-
end
|
533
|
-
|
534
|
-
# The #{onMouseEnter} method is called by SketchUp when the mouse enters the
|
535
|
-
# viewport.
|
536
|
-
#
|
537
|
-
# @example
|
538
|
-
# def onMouseEnter(view)
|
539
|
-
# puts "onMouseEnter: view = #{view}"
|
540
|
-
# end
|
541
|
-
#
|
542
|
-
# @param [Sketchup::View] view
|
543
|
-
#
|
544
|
-
# @version SketchUp 6.0
|
545
|
-
def onMouseEnter(view)
|
546
|
-
end
|
547
|
-
|
548
|
-
# The #{onMouseLeave} method is called by SketchUp when the mouse leaves the
|
549
|
-
# viewport.
|
550
|
-
#
|
551
|
-
# @example
|
552
|
-
# def onMouseLeave(view)
|
553
|
-
# puts "onMouseLeave: view = #{view}"
|
554
|
-
# end
|
555
|
-
#
|
556
|
-
# @param [Sketchup::View] view
|
557
|
-
#
|
558
|
-
# @version SketchUp 6.0
|
559
|
-
def onMouseLeave(view)
|
560
|
-
end
|
561
|
-
|
562
|
-
# The #{onMouseMove} method is called by SketchUp whenever the mouse is moved.
|
563
|
-
# You will often want to implement this method.
|
564
|
-
#
|
565
|
-
# Try to make this method as efficient as possible because this method is
|
566
|
-
# called often.
|
567
|
-
#
|
568
|
-
# @example
|
569
|
-
# def onMouseMove(flags, x, y, view)
|
570
|
-
# puts "onMouseMove: flags = #{flags}"
|
571
|
-
# puts " x = #{x}"
|
572
|
-
# puts " y = #{y}"
|
573
|
-
# puts " view = #{view}"
|
574
|
-
# end
|
575
|
-
#
|
576
|
-
# @param [Integer] flags
|
577
|
-
# A bit mask that tells the state of the modifier
|
578
|
-
# keys and other mouse buttons at the time.
|
579
|
-
#
|
580
|
-
# @param [Integer] x
|
581
|
-
# The X coordinate on the screen where the event occurred.
|
582
|
-
#
|
583
|
-
# @param [Integer] y
|
584
|
-
# The Y coordinate on the screen where the event occurred.
|
585
|
-
#
|
586
|
-
# @param [Sketchup::View] view
|
587
|
-
#
|
588
|
-
# @version SketchUp 6.0
|
589
|
-
def onMouseMove(flags, x, y, view)
|
590
|
-
end
|
591
|
-
|
592
|
-
# The #{onMouseWheel} method is called by SketchUp when the mouse scroll wheel
|
593
|
-
# is used.
|
594
|
-
#
|
595
|
-
# @example
|
596
|
-
# class ExampleTool
|
597
|
-
#
|
598
|
-
# def initialize
|
599
|
-
# @property_value = 0
|
600
|
-
# @rect = [
|
601
|
-
# Geom::Point3d.new(100, 150, 0),
|
602
|
-
# Geom::Point3d.new(300, 150, 0),
|
603
|
-
# Geom::Point3d.new(300, 250, 0),
|
604
|
-
# Geom::Point3d.new(100, 250, 0),
|
605
|
-
# ]
|
606
|
-
# end
|
607
|
-
#
|
608
|
-
# def onMouseMove(flags, x, y, view)
|
609
|
-
# view.invalidate
|
610
|
-
# end
|
611
|
-
#
|
612
|
-
# def onMouseWheel(flags, delta, x, y, view)
|
613
|
-
# # If the cursor is not within the bounds of the rectangle, return false
|
614
|
-
# # to let SketchUp do its default action (zoom).
|
615
|
-
# point = Geom::Point3d.new(x, y)
|
616
|
-
# return false unless Geom.point_in_polygon_2D(point, @rect, true)
|
617
|
-
#
|
618
|
-
# # If cursor is within the bounds of the rectangle, update the value
|
619
|
-
# # and prevent the default zoom.
|
620
|
-
# @property_value += delta
|
621
|
-
# view.invalidate
|
622
|
-
# true
|
623
|
-
# end
|
624
|
-
#
|
625
|
-
# def draw(view)
|
626
|
-
# view.line_width = 2
|
627
|
-
# view.line_stipple = ''
|
628
|
-
# view.drawing_color = 'red'
|
629
|
-
# view.draw2d(GL_QUADS, @rect)
|
630
|
-
#
|
631
|
-
# point = Geom::Point3d.new(120, 170)
|
632
|
-
# view.draw_text(point, "Value: #{@property_value}",
|
633
|
-
# size: 20, bold: true, color: 'black')
|
634
|
-
# end
|
635
|
-
#
|
636
|
-
# end
|
637
|
-
#
|
638
|
-
# Sketchup.active_model.select_tool(ExampleTool.new)
|
639
|
-
#
|
640
|
-
# @param [Integer] flags
|
641
|
-
# A bit mask that tells the state of the modifier
|
642
|
-
# keys and other mouse buttons at the time.
|
643
|
-
#
|
644
|
-
# @param [Integer] delta
|
645
|
-
# Either +1+ or +-1+ depending on which direction the
|
646
|
-
# mouse wheel scrolled.
|
647
|
-
#
|
648
|
-
# @param [Float] x
|
649
|
-
# The X coordinate on the screen where the event occurred.
|
650
|
-
#
|
651
|
-
# @param [Float] y
|
652
|
-
# The Y coordinate on the screen where the event occurred.
|
653
|
-
#
|
654
|
-
# @param [Sketchup::View] view
|
655
|
-
#
|
656
|
-
# @return [Boolean] Return +true+ to prevent SketchUp from performing default
|
657
|
-
# zoom action.
|
658
|
-
#
|
659
|
-
# @version SketchUp 2019.2
|
660
|
-
def onMouseWheel(flags, delta, x, y, view)
|
661
|
-
end
|
662
|
-
|
663
|
-
# The #{onRButtonDoubleClick} is called by SketchUp when the user double clicks
|
664
|
-
# with the right mouse button.
|
665
|
-
#
|
666
|
-
# @example
|
667
|
-
# def onRButtonDoubleClick(flags, x, y, view)
|
668
|
-
# puts "onRButtonDoubleClick: flags = #{flags}"
|
669
|
-
# puts " x = #{x}"
|
670
|
-
# puts " y = #{y}"
|
671
|
-
# puts " view = #{view}"
|
672
|
-
# end
|
673
|
-
#
|
674
|
-
# @param [Integer] flags
|
675
|
-
# A bit mask that tells the state of the modifier
|
676
|
-
# keys and other mouse buttons at the time.
|
677
|
-
#
|
678
|
-
# @param [Integer] x
|
679
|
-
# The X coordinate on the screen where the event occurred.
|
680
|
-
#
|
681
|
-
# @param [Integer] y
|
682
|
-
# The Y coordinate on the screen where the event occurred.
|
683
|
-
#
|
684
|
-
# @param [Sketchup::View] view
|
685
|
-
#
|
686
|
-
# @version SketchUp 6.0
|
687
|
-
def onRButtonDoubleClick(flags, x, y, view)
|
688
|
-
end
|
689
|
-
|
690
|
-
# The #{onRButtonDown} method is called by SketchUp when the user presses
|
691
|
-
# the right mouse button. Implement this method, along with the tool.getMenu
|
692
|
-
# method, when you want your tool to do something other than display the
|
693
|
-
# default context menu when the right mouse button is clicked.
|
694
|
-
#
|
695
|
-
# @example
|
696
|
-
# def onRButtonDown(flags, x, y, view)
|
697
|
-
# puts "onRButtonDown: flags = #{flags}"
|
698
|
-
# puts " x = #{x}"
|
699
|
-
# puts " y = #{y}"
|
700
|
-
# puts " view = #{view}"
|
701
|
-
# end
|
702
|
-
#
|
703
|
-
# @param [Integer] flags
|
704
|
-
# A bit mask that tells the state of the modifier
|
705
|
-
# keys and other mouse buttons at the time.
|
706
|
-
#
|
707
|
-
# @param [Integer] x
|
708
|
-
# The X coordinate on the screen where the event occurred.
|
709
|
-
#
|
710
|
-
# @param [Integer] y
|
711
|
-
# The Y coordinate on the screen where the event occurred.
|
712
|
-
#
|
713
|
-
# @param [Sketchup::View] view
|
714
|
-
#
|
715
|
-
# @version SketchUp 6.0
|
716
|
-
def onRButtonDown(flags, x, y, view)
|
717
|
-
end
|
718
|
-
|
719
|
-
# The #{onRButtonUp} method is called by SketchUp when the user releases the
|
720
|
-
# right mouse button.
|
721
|
-
#
|
722
|
-
# @example
|
723
|
-
# def onRButtonUp(flags, x, y, view)
|
724
|
-
# puts "onRButtonUp: flags = #{flags}"
|
725
|
-
# puts " x = #{x}"
|
726
|
-
# puts " y = #{y}"
|
727
|
-
# puts " view = #{view}"
|
728
|
-
# end
|
729
|
-
#
|
730
|
-
# @param [Integer] flags
|
731
|
-
# A bit mask that tells the state of the modifier
|
732
|
-
# keys and other mouse buttons at the time.
|
733
|
-
#
|
734
|
-
# @param [Integer] x
|
735
|
-
# The X coordinate on the screen where the event occurred.
|
736
|
-
#
|
737
|
-
# @param [Integer] y
|
738
|
-
# The Y coordinate on the screen where the event occurred.
|
739
|
-
#
|
740
|
-
# @param [Sketchup::View] view
|
741
|
-
#
|
742
|
-
# @version SketchUp 6.0
|
743
|
-
def onRButtonUp(flags, x, y, view)
|
744
|
-
end
|
745
|
-
|
746
|
-
# The {#onReturn} method is called by SketchUp when the user hit the Return key
|
747
|
-
# to complete an operation in the tool. This method will rarely need to be
|
748
|
-
# implemented.
|
749
|
-
#
|
750
|
-
# @example
|
751
|
-
# def onReturn(view)
|
752
|
-
# puts "onReturn(#{view})"
|
753
|
-
# end
|
754
|
-
#
|
755
|
-
# @param [Sketchup::View] view
|
756
|
-
#
|
757
|
-
# @return [nil]
|
758
|
-
#
|
759
|
-
# @version SketchUp 6.0
|
760
|
-
def onReturn(view)
|
761
|
-
end
|
762
|
-
|
763
|
-
# The #{onSetCursor} method is called by SketchUp when the tool wants to set
|
764
|
-
# the cursor.
|
765
|
-
#
|
766
|
-
# @example
|
767
|
-
# def onSetCursor
|
768
|
-
# puts "onSetCursor: view = #{view}"
|
769
|
-
# # You would set your cursor here. See UI.set_cursor method.
|
770
|
-
# UI.set_cursor(@cursor_id) # UI.set_cursor return true
|
771
|
-
# end
|
772
|
-
#
|
773
|
-
# @return [Boolean] Return +true+ to prevent SketchUp using the default cursor.
|
774
|
-
#
|
775
|
-
# @version SketchUp 6.0
|
776
|
-
def onSetCursor
|
777
|
-
end
|
778
|
-
|
779
|
-
# The {#onUserText} method is called by SketchUp when the user has typed text
|
780
|
-
# into the VCB and hit return.
|
781
|
-
#
|
782
|
-
# @example
|
783
|
-
# def onUserText(text, view)
|
784
|
-
# @distance = text.to_l
|
785
|
-
# rescue ArgumentError
|
786
|
-
# view.tooltop = 'Invalid length'
|
787
|
-
# end
|
788
|
-
#
|
789
|
-
# @param [String] text
|
790
|
-
# The text string that was typed into the VCB.
|
791
|
-
#
|
792
|
-
# @param [Sketchup::View] view
|
793
|
-
# A view object where the method was invoked.
|
794
|
-
#
|
795
|
-
# @version SketchUp 6.0
|
796
|
-
def onUserText(text, view)
|
797
|
-
end
|
798
|
-
|
799
|
-
# The #{resume} method is called by SketchUp when the tool becomes active again
|
800
|
-
# after being suspended.
|
801
|
-
#
|
802
|
-
# @example
|
803
|
-
# def resume(view)
|
804
|
-
# puts "resume: view = #{view}"
|
805
|
-
# end
|
806
|
-
#
|
807
|
-
# @param [Sketchup::View] view
|
808
|
-
#
|
809
|
-
# @version SketchUp 6.0
|
810
|
-
def resume(view)
|
811
|
-
end
|
812
|
-
|
813
|
-
# The #{suspend} method is called by SketchUp when the tool temporarily becomes
|
814
|
-
# inactive because another tool has been activated. This typically happens
|
815
|
-
# when a viewing tool is activated, such as when orbit is active due to the
|
816
|
-
# middle mouse button.
|
817
|
-
#
|
818
|
-
# @example
|
819
|
-
# def suspend(view)
|
820
|
-
# puts "suspend: view = #{view}"
|
821
|
-
# end
|
822
|
-
#
|
823
|
-
# @param [Sketchup::View] view
|
824
|
-
#
|
825
|
-
# @version SketchUp 6.0
|
826
|
-
def suspend(view)
|
827
|
-
end
|
828
|
-
|
829
|
-
end
|
1
|
+
# Copyright:: Copyright 2020 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# Tool is the interface that you implement to create a SketchUp tool.
|
5
|
+
# See https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/master/examples/02_custom_tool
|
6
|
+
# for an example of how to create a custom tool in Ruby.
|
7
|
+
#
|
8
|
+
# To create a new tool in Ruby, you must define a new class that implements
|
9
|
+
# the methods for the events that you want to respond to. You do not have
|
10
|
+
# to implement methods for every possible event that a Tool can respond to.
|
11
|
+
#
|
12
|
+
# Once you have defined a tool class, you select that tool by creating an
|
13
|
+
# instance of it and passing it to {Sketchup::Model#select_tool}. For
|
14
|
+
# example:
|
15
|
+
#
|
16
|
+
# class MyTool
|
17
|
+
# def activate
|
18
|
+
# puts 'Your tool has been activated.'
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# my_tool = MyTool.new
|
23
|
+
# Sketchup.active_model.select_tool(my_tool)
|
24
|
+
#
|
25
|
+
# The following table contains several constants you can use when check for
|
26
|
+
# certain key presses inside the keyboard handling callbacks:
|
27
|
+
#
|
28
|
+
# - +CONSTRAIN_MODIFIER_KEY+ = Shift Key
|
29
|
+
# - +CONSTRAIN_MODIFIER_MASK+ = Shift Key
|
30
|
+
# - +COPY_MODIFIER_KEY+ = Alt/Option on Mac, Ctrl on PC
|
31
|
+
# - +COPY_MODIFIER_MASK+ = Alt/Option on Mac, Ctrl on PC
|
32
|
+
# - +ALT_MODIFIER_KEY+ = Command on Mac, Alt on PC
|
33
|
+
# - +ALT_MODIFIER_MASK+ = Command on Mac, Alt on PC
|
34
|
+
#
|
35
|
+
# @version SketchUp 6.0
|
36
|
+
class Sketchup::Tool
|
37
|
+
|
38
|
+
# Instance Methods
|
39
|
+
|
40
|
+
# The #{activate} method is called by SketchUp when the tool is selected.
|
41
|
+
# It is a good place to put most of your initialization, such as instance
|
42
|
+
# variables to track the state of the tool.
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# def activate
|
46
|
+
# puts 'Your tool has been activated.'
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# @version SketchUp 6.0
|
50
|
+
def activate
|
51
|
+
end
|
52
|
+
|
53
|
+
# The #{deactivate} method is called when the tool is deactivated because a
|
54
|
+
# different tool was selected.
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# def deactivate(view)
|
58
|
+
# puts "Your tool has been deactivated in view: #{view}"
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# @param [Sketchup::View] view
|
62
|
+
#
|
63
|
+
# @version SketchUp 6.0
|
64
|
+
def deactivate(view)
|
65
|
+
end
|
66
|
+
|
67
|
+
# The {#draw} method is called by SketchUp whenever the view is refreshed to
|
68
|
+
# allow the tool to do its own drawing. If the tool has some temporary graphics
|
69
|
+
# that it wants displayed while it is active, it should implement this method
|
70
|
+
# and draw to the {Sketchup::View}.
|
71
|
+
#
|
72
|
+
# @example
|
73
|
+
# def draw(view)
|
74
|
+
# # Draw a square.
|
75
|
+
# points = [
|
76
|
+
# Geom::Point3d.new(0, 0, 0),
|
77
|
+
# Geom::Point3d.new(9, 0, 0),
|
78
|
+
# Geom::Point3d.new(9, 9, 0),
|
79
|
+
# Geom::Point3d.new(0, 9, 0)
|
80
|
+
# ]
|
81
|
+
# # Fill
|
82
|
+
# view.drawing_color = Sketchup::Color.new(255, 128, 128)
|
83
|
+
# view.draw(GL_QUADS, points)
|
84
|
+
# # Outline
|
85
|
+
# view.line_stipple = '' # Solid line
|
86
|
+
# view.drawing_color = Sketchup::Color.new(64, 0, 0)
|
87
|
+
# view.draw(GL_LINE_LOOP, points)
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# @note If you draw outside the model bounds you need to implement
|
91
|
+
# {Tool#getExtents} which return a bounding box large enough to include the
|
92
|
+
# points you draw. Otherwise your drawing will be clipped.
|
93
|
+
#
|
94
|
+
# @param [Sketchup::View] view
|
95
|
+
# A View object where the method was invoked.
|
96
|
+
#
|
97
|
+
# @see getExtents
|
98
|
+
#
|
99
|
+
# @see Sketchup::View#draw
|
100
|
+
#
|
101
|
+
# @version SketchUp 6.0
|
102
|
+
def draw(view)
|
103
|
+
end
|
104
|
+
|
105
|
+
# The #{enableVCB?} method is used to tell SketchUp whether to allow the user
|
106
|
+
# to enter text into the VCB (value control box, aka the "measurements" panel).
|
107
|
+
# If you do not implement this method, then the vcb is disabled by default.
|
108
|
+
#
|
109
|
+
# @example
|
110
|
+
# # For this tool, allow vcb text entry while the tool is active.
|
111
|
+
# def enableVCB?
|
112
|
+
# return true
|
113
|
+
# end
|
114
|
+
#
|
115
|
+
# @return [Boolean] Return +true+ if you want the VCB enabled
|
116
|
+
#
|
117
|
+
# @version SketchUp 6.0
|
118
|
+
def enableVCB?
|
119
|
+
end
|
120
|
+
|
121
|
+
# In order to accurately draw things, SketchUp needs to know the extents of
|
122
|
+
# what it is drawing. If the tool is doing its own drawing, it may need to
|
123
|
+
# implement this method to tell SketchUp the extents of what it will be
|
124
|
+
# drawing. If you don't implement this method, you may find that part of what
|
125
|
+
# the tool is drawing gets clipped to the extents of the rest of the
|
126
|
+
# model.
|
127
|
+
#
|
128
|
+
# This must return a {Geom::BoundingBox}. In a typical implementation, you
|
129
|
+
# will create a new {Geom::BoundingBox}, add points to set the extents of the
|
130
|
+
# drawing that the tool will do and then return it.
|
131
|
+
#
|
132
|
+
# @example
|
133
|
+
# def getExtents
|
134
|
+
# bb = Sketchup.active_model.bounds
|
135
|
+
# return bb
|
136
|
+
# end
|
137
|
+
#
|
138
|
+
# @return [Geom::BoundingBox]
|
139
|
+
#
|
140
|
+
# @version SketchUp 6.0
|
141
|
+
def getExtents
|
142
|
+
end
|
143
|
+
|
144
|
+
# The #{getInstructorContentDirectory} method is used to tell SketchUp the
|
145
|
+
# directory containing your Tool's instructor content. To use this, create
|
146
|
+
# a custom instructor directory, put an index.html file inside of it, and then
|
147
|
+
# return that path via this method. If the SketchUp user has the Instructor
|
148
|
+
# window open when they activate your tool, they will see your html file.
|
149
|
+
#
|
150
|
+
# @example
|
151
|
+
# def getInstructorContentDirectory
|
152
|
+
# extension_path = Sketchup.extensions['MyExtension].extension_path
|
153
|
+
# instructor_path = File.join(extension_path, 'MyExtension', 'instructor')
|
154
|
+
# return instructor_path
|
155
|
+
# end
|
156
|
+
#
|
157
|
+
# @note Prior to SketchUp 2014 this method would assume the path was relative
|
158
|
+
# to the SketchUp resource folder. From 2014 and onwards you can specify the
|
159
|
+
# absolute path to an HTML file or the absolute path to a directory
|
160
|
+
# containing an index.html file.
|
161
|
+
#
|
162
|
+
# @return [String] the directory path where the Instructor content exists.
|
163
|
+
#
|
164
|
+
# @version SketchUp 6.0
|
165
|
+
def getInstructorContentDirectory
|
166
|
+
end
|
167
|
+
|
168
|
+
# The #{getMenu} method is called by SketchUp to let the tool provide its own
|
169
|
+
# context menu. Most tools will not want to implement this method and,
|
170
|
+
# instead, use the normal context menu found on all entities.
|
171
|
+
#
|
172
|
+
# If you do implement this method, the argument is a Menu. You should use the
|
173
|
+
# add_item method to build the context menu.
|
174
|
+
#
|
175
|
+
# Your tool will use a standard context menu by default if you do not
|
176
|
+
# implement this method. Implement this method if you want a context-click to
|
177
|
+
# display something other than this default context menu.
|
178
|
+
#
|
179
|
+
# In SketchUp 2015 the flags, x, y and view parameters were added. They are
|
180
|
+
# needed if you need to pick the entities under the mouse position. The new
|
181
|
+
# parameters are optional, but if you need to use one you must include them
|
182
|
+
# all.
|
183
|
+
#
|
184
|
+
# @example
|
185
|
+
# if Sketchup.version.to_i < 15
|
186
|
+
# # Compatible with SketchUp 2014 and older:
|
187
|
+
# def getMenu(menu)
|
188
|
+
# menu.add_item('Say Hello') {
|
189
|
+
# UI.messagebox('Hello')
|
190
|
+
# }
|
191
|
+
# end
|
192
|
+
# else
|
193
|
+
# # Only works with SketchUp 2015 and newer:
|
194
|
+
# def getMenu(menu, flags, x, y, view)
|
195
|
+
# ph = view.pick_helper(x, y)
|
196
|
+
# entity = ph.best_picked
|
197
|
+
# if entity
|
198
|
+
# view.model.selection.clear
|
199
|
+
# view.model.selection.add(entity)
|
200
|
+
# menu.add_item("Erase #{entity.typename}") {
|
201
|
+
# entity.erase!
|
202
|
+
# }
|
203
|
+
# end
|
204
|
+
# end
|
205
|
+
# end
|
206
|
+
#
|
207
|
+
# @param menu
|
208
|
+
# A Menu object.
|
209
|
+
#
|
210
|
+
# @param [optional] flags
|
211
|
+
# A bit mask that tells the state of the
|
212
|
+
# modifier keys and other mouse buttons at the time.
|
213
|
+
# Added in SU2015.
|
214
|
+
#
|
215
|
+
# @param [optional] x
|
216
|
+
# The X coordinate on the screen where the
|
217
|
+
# event occurred. Added in SU2015.
|
218
|
+
#
|
219
|
+
# @param [optional] y
|
220
|
+
# The Y coordinate on the screen where the
|
221
|
+
# event occurred. Added in SU2015.
|
222
|
+
#
|
223
|
+
# @param [optional] view
|
224
|
+
# A View object where the method was invoked.
|
225
|
+
# Added in SU2015.
|
226
|
+
#
|
227
|
+
# @return nil
|
228
|
+
#
|
229
|
+
# @version SketchUp 6.0
|
230
|
+
def getMenu(menu, flags, x, y, view)
|
231
|
+
end
|
232
|
+
|
233
|
+
# The {#onCancel} method is called by SketchUp to cancel the current operation
|
234
|
+
# of the tool. The typical response will be to reset the tool to its initial
|
235
|
+
# state.
|
236
|
+
#
|
237
|
+
# The reason identifies the action that triggered the call. The reason can be
|
238
|
+
# one of the following values:
|
239
|
+
#
|
240
|
+
# - +0+: the user canceled the current operation by hitting the escape key.
|
241
|
+
# - +1+: the user re-selected the same tool from the toolbar or menu.
|
242
|
+
# - +2+: the user did an undo while the tool was active.
|
243
|
+
#
|
244
|
+
# @example
|
245
|
+
# def onCancel(reason, view)
|
246
|
+
# puts "MyTool was canceled for reason ##{reason} in view: #{view}"
|
247
|
+
# end
|
248
|
+
#
|
249
|
+
# @note When something is undone {#onCancel} is called before the undo is
|
250
|
+
# actually executed. If you need to do something with the model after an undo
|
251
|
+
# use {Sketchup::ModelObserver#onTransactionUndo}.
|
252
|
+
#
|
253
|
+
# @param [Integer] reason
|
254
|
+
# A reason value (see comments).
|
255
|
+
#
|
256
|
+
# @param [Sketchup::View] view
|
257
|
+
#
|
258
|
+
# @version SketchUp 6.0
|
259
|
+
def onCancel(reason, view)
|
260
|
+
end
|
261
|
+
|
262
|
+
# The #{onKeyDown} method is called by SketchUp when the user presses a key on
|
263
|
+
# the keyboard. If you want to get input from the VCB, you should implement
|
264
|
+
# onUserText rather than this method.
|
265
|
+
#
|
266
|
+
# This method is can be used for special keys such as the Shift key, Ctrl key,
|
267
|
+
# and so on, or for just determining which key a user pressed. This method is
|
268
|
+
# actually called for all keys that are pressed.
|
269
|
+
#
|
270
|
+
# There are several
|
271
|
+
# "virtual keys" defined as constants you can use. Their use is cross
|
272
|
+
# platform. They are:
|
273
|
+
#
|
274
|
+
# - +VK_ALT+
|
275
|
+
# - +VK_COMMAND+
|
276
|
+
# - +VK_CONTROL+
|
277
|
+
# - +VK_DELETE+
|
278
|
+
# - +VK_DOWN+
|
279
|
+
# - +VK_END+
|
280
|
+
# - +VK_HOME+
|
281
|
+
# - +VK_INSERT+
|
282
|
+
# - +VK_LEFT+
|
283
|
+
# - +VK_MENU+
|
284
|
+
# - +VK_NEXT+
|
285
|
+
# - +VK_PRIOR+
|
286
|
+
# - +VK_RIGHT+
|
287
|
+
# - +VK_SHIFT+
|
288
|
+
# - +VK_SPACE+
|
289
|
+
# - +VK_UP+
|
290
|
+
#
|
291
|
+
# V6: There is a bug on Windows where the typematic effect does
|
292
|
+
# not work. Typematic effects work fine on a Mac.
|
293
|
+
#
|
294
|
+
# @example
|
295
|
+
# def onKeyDown(key, repeat, flags, view)
|
296
|
+
# puts "onKeyDown: key = #{key}"
|
297
|
+
# puts " repeat = #{repeat}"
|
298
|
+
# puts " flags = #{flags}"
|
299
|
+
# puts " view = #{view}"
|
300
|
+
# end
|
301
|
+
#
|
302
|
+
# @param [Integer] key
|
303
|
+
# The key that was pressed.
|
304
|
+
#
|
305
|
+
# @param [Integer] repeat
|
306
|
+
# A value of 1 for a single press of a key. A value
|
307
|
+
# of 2 if the user has pressed a key and is holding
|
308
|
+
# it down.
|
309
|
+
#
|
310
|
+
# @param [Integer] flags
|
311
|
+
# A bit mask that tells the state of the modifier
|
312
|
+
# keys at the time of the event.
|
313
|
+
#
|
314
|
+
# @param [Sketchup::View] view
|
315
|
+
#
|
316
|
+
# @return [Boolean] Return +true+ to prevent SketchUp from processing the
|
317
|
+
# event.
|
318
|
+
#
|
319
|
+
# @version SketchUp 6.0
|
320
|
+
def onKeyDown(key, repeat, flags, view)
|
321
|
+
end
|
322
|
+
|
323
|
+
# The #{onKeyUp} method is called by SketchUp when the user releases a key on
|
324
|
+
# the keyboard.
|
325
|
+
#
|
326
|
+
# @example
|
327
|
+
# def onKeyUp(key, repeat, flags, view)
|
328
|
+
# puts "onKeyUp: key = #{key}"
|
329
|
+
# puts " repeat = #{repeat}"
|
330
|
+
# puts " flags = #{flags}"
|
331
|
+
# puts " view = #{view}"
|
332
|
+
# end
|
333
|
+
#
|
334
|
+
# @param [Integer] key
|
335
|
+
# The key that was pressed.
|
336
|
+
#
|
337
|
+
# @param [Integer] repeat
|
338
|
+
# A value of 1 for a single press of a key. A value
|
339
|
+
# of 2 if the user has pressed a key and is holding
|
340
|
+
# it down.
|
341
|
+
#
|
342
|
+
# @param [Integer] flags
|
343
|
+
# A bit mask that tells the state of the modifier
|
344
|
+
# keys at the time of the event.
|
345
|
+
#
|
346
|
+
# @param [Sketchup::View] view
|
347
|
+
#
|
348
|
+
# @return [Boolean] Return +true+ to prevent SketchUp from processing the
|
349
|
+
# event.
|
350
|
+
#
|
351
|
+
# @version SketchUp 6.0
|
352
|
+
def onKeyUp(key, repeat, flags, view)
|
353
|
+
end
|
354
|
+
|
355
|
+
# The #{onLButtonDoubleClick} is called by SketchUp when the user double clicks
|
356
|
+
# with the left mouse button.
|
357
|
+
#
|
358
|
+
# @example
|
359
|
+
# def onLButtonDoubleClick(flags, x, y, view)
|
360
|
+
# puts "onLButtonDoubleClick: flags = #{flags}"
|
361
|
+
# puts " x = #{x}"
|
362
|
+
# puts " y = #{y}"
|
363
|
+
# puts " view = #{view}"
|
364
|
+
# end
|
365
|
+
#
|
366
|
+
# @param [Integer] flags
|
367
|
+
# A bit mask that tells the state of the modifier
|
368
|
+
# keys and other mouse buttons at the time.
|
369
|
+
#
|
370
|
+
# @param [Integer] x
|
371
|
+
# The X coordinate on the screen where the event occurred.
|
372
|
+
#
|
373
|
+
# @param [Integer] y
|
374
|
+
# The Y coordinate on the screen where the event occurred.
|
375
|
+
#
|
376
|
+
# @param [Sketchup::View] view
|
377
|
+
#
|
378
|
+
# @version SketchUp 6.0
|
379
|
+
def onLButtonDoubleClick(flags, x, y, view)
|
380
|
+
end
|
381
|
+
|
382
|
+
# The #{onLButtonDown} method is called by SketchUp when the left mouse button
|
383
|
+
# is pressed. Most tools will implement this method.
|
384
|
+
#
|
385
|
+
# @example
|
386
|
+
# def onLButtonDown(flags, x, y, view)
|
387
|
+
# puts "onLButtonDown: flags = #{flags}"
|
388
|
+
# puts " x = #{x}"
|
389
|
+
# puts " y = #{y}"
|
390
|
+
# puts " view = #{view}"
|
391
|
+
# end
|
392
|
+
#
|
393
|
+
# @param [Integer] flags
|
394
|
+
# A bit mask that tells the state of the modifier
|
395
|
+
# keys and other mouse buttons at the time.
|
396
|
+
#
|
397
|
+
# @param [Integer] x
|
398
|
+
# The X coordinate on the screen where the event occurred.
|
399
|
+
#
|
400
|
+
# @param [Integer] y
|
401
|
+
# The Y coordinate on the screen where the event occurred.
|
402
|
+
#
|
403
|
+
# @param [Sketchup::View] view
|
404
|
+
#
|
405
|
+
# @version SketchUp 6.0
|
406
|
+
def onLButtonDown(flags, x, y, view)
|
407
|
+
end
|
408
|
+
|
409
|
+
# The #{onLButtonUp} method is called by SketchUp when the left mouse button is
|
410
|
+
# released.
|
411
|
+
#
|
412
|
+
# @example
|
413
|
+
# def onLButtonUp(flags, x, y, view)
|
414
|
+
# puts "onLButtonUp: flags = #{flags}"
|
415
|
+
# puts " x = #{x}"
|
416
|
+
# puts " y = #{y}"
|
417
|
+
# puts " view = #{view}"
|
418
|
+
# end
|
419
|
+
#
|
420
|
+
# @param [Integer] flags
|
421
|
+
# A bit mask that tells the state of the modifier
|
422
|
+
# keys and other mouse buttons at the time.
|
423
|
+
#
|
424
|
+
# @param [Integer] x
|
425
|
+
# The X coordinate on the screen where the event occurred.
|
426
|
+
#
|
427
|
+
# @param [Integer] y
|
428
|
+
# The Y coordinate on the screen where the event occurred.
|
429
|
+
#
|
430
|
+
# @param [Sketchup::View] view
|
431
|
+
#
|
432
|
+
# @version SketchUp 6.0
|
433
|
+
def onLButtonUp(flags, x, y, view)
|
434
|
+
end
|
435
|
+
|
436
|
+
# The #{onMButtonDoubleClick} method is called by SketchUp when the middle
|
437
|
+
# mouse button (on a three button mouse) is double-clicked.
|
438
|
+
#
|
439
|
+
# Only implement this method if you want SketchUp to react to a middle mouse
|
440
|
+
# button being double-clicked.
|
441
|
+
#
|
442
|
+
# @example
|
443
|
+
# def onMButtonDoubleClick(flags, x, y, view)
|
444
|
+
# puts "onMButtonDoubleClick: flags = #{flags}"
|
445
|
+
# puts " x = #{x}"
|
446
|
+
# puts " y = #{y}"
|
447
|
+
# puts " view = #{view}"
|
448
|
+
# end
|
449
|
+
#
|
450
|
+
# @note Though this method has been documented in the Ruby API for many years,
|
451
|
+
# it has never worked properly. We are leaving this documentation in place
|
452
|
+
# for now in the hopes of fixing the implementation, but you won't have any
|
453
|
+
# luck trying to use it in SU7 and earlier.
|
454
|
+
#
|
455
|
+
# @param [Integer] flags
|
456
|
+
# A bit mask that tells the state of the modifier
|
457
|
+
# keys and other mouse buttons at the time.
|
458
|
+
#
|
459
|
+
# @param [Integer] x
|
460
|
+
# The X coordinate on the screen where the event occurred.
|
461
|
+
#
|
462
|
+
# @param [Integer] y
|
463
|
+
# The Y coordinate on the screen where the event occurred.
|
464
|
+
#
|
465
|
+
# @param [Sketchup::View] view
|
466
|
+
#
|
467
|
+
# @version SketchUp 6.0
|
468
|
+
def onMButtonDoubleClick(flags, x, y, view)
|
469
|
+
end
|
470
|
+
|
471
|
+
# The #{onMButtonDown} method is called by SketchUp when the middle mouse
|
472
|
+
# button (on a three button mouse) is down.
|
473
|
+
#
|
474
|
+
# The Orbit tool is activated by default when the middle mouse button is down.
|
475
|
+
# Implement this method if you want a middle mouse button to do something
|
476
|
+
# other than invoke the Orbit tool.
|
477
|
+
#
|
478
|
+
# @example
|
479
|
+
# def onMButtonDown(flags, x, y, view)
|
480
|
+
# puts "onMButtonDown: flags = #{flags}"
|
481
|
+
# puts " x = #{x}"
|
482
|
+
# puts " y = #{y}"
|
483
|
+
# puts " view = #{view}"
|
484
|
+
# end
|
485
|
+
#
|
486
|
+
# @param [Integer] flags
|
487
|
+
# A bit mask that tells the state of the modifier
|
488
|
+
# keys and other mouse buttons at the time.
|
489
|
+
#
|
490
|
+
# @param [Integer] x
|
491
|
+
# The X coordinate on the screen where the event occurred.
|
492
|
+
#
|
493
|
+
# @param [Integer] y
|
494
|
+
# The Y coordinate on the screen where the event occurred.
|
495
|
+
#
|
496
|
+
# @param [Sketchup::View] view
|
497
|
+
#
|
498
|
+
# @version SketchUp 6.0
|
499
|
+
def onMButtonDown(flags, x, y, view)
|
500
|
+
end
|
501
|
+
|
502
|
+
# The #{onMButtonUp} method is called by SketchUp when the middle mouse button
|
503
|
+
# (on a three button mouse) is released.
|
504
|
+
#
|
505
|
+
# SketchUp returns to the previous tool from the Orbit tool when the middle
|
506
|
+
# mouse button is released. Implement this method if you want a middle mouse
|
507
|
+
# button to do something other than return to the previous tool when in the
|
508
|
+
# Orbit tool.
|
509
|
+
#
|
510
|
+
# @example
|
511
|
+
# def onMButtonUp(flags, x, y, view)
|
512
|
+
# puts "onMButtonUp: flags = #{flags}"
|
513
|
+
# puts " x = #{x}"
|
514
|
+
# puts " y = #{y}"
|
515
|
+
# puts " view = #{view}"
|
516
|
+
# end
|
517
|
+
#
|
518
|
+
# @param [Integer] flags
|
519
|
+
# A bit mask that tells the state of the modifier
|
520
|
+
# keys and other mouse buttons at the time.
|
521
|
+
#
|
522
|
+
# @param [Integer] x
|
523
|
+
# The X coordinate on the screen where the event occurred.
|
524
|
+
#
|
525
|
+
# @param [Integer] y
|
526
|
+
# The Y coordinate on the screen where the event occurred.
|
527
|
+
#
|
528
|
+
# @param [Sketchup::View] view
|
529
|
+
#
|
530
|
+
# @version SketchUp 6.0
|
531
|
+
def onMButtonUp(flags, x, y, view)
|
532
|
+
end
|
533
|
+
|
534
|
+
# The #{onMouseEnter} method is called by SketchUp when the mouse enters the
|
535
|
+
# viewport.
|
536
|
+
#
|
537
|
+
# @example
|
538
|
+
# def onMouseEnter(view)
|
539
|
+
# puts "onMouseEnter: view = #{view}"
|
540
|
+
# end
|
541
|
+
#
|
542
|
+
# @param [Sketchup::View] view
|
543
|
+
#
|
544
|
+
# @version SketchUp 6.0
|
545
|
+
def onMouseEnter(view)
|
546
|
+
end
|
547
|
+
|
548
|
+
# The #{onMouseLeave} method is called by SketchUp when the mouse leaves the
|
549
|
+
# viewport.
|
550
|
+
#
|
551
|
+
# @example
|
552
|
+
# def onMouseLeave(view)
|
553
|
+
# puts "onMouseLeave: view = #{view}"
|
554
|
+
# end
|
555
|
+
#
|
556
|
+
# @param [Sketchup::View] view
|
557
|
+
#
|
558
|
+
# @version SketchUp 6.0
|
559
|
+
def onMouseLeave(view)
|
560
|
+
end
|
561
|
+
|
562
|
+
# The #{onMouseMove} method is called by SketchUp whenever the mouse is moved.
|
563
|
+
# You will often want to implement this method.
|
564
|
+
#
|
565
|
+
# Try to make this method as efficient as possible because this method is
|
566
|
+
# called often.
|
567
|
+
#
|
568
|
+
# @example
|
569
|
+
# def onMouseMove(flags, x, y, view)
|
570
|
+
# puts "onMouseMove: flags = #{flags}"
|
571
|
+
# puts " x = #{x}"
|
572
|
+
# puts " y = #{y}"
|
573
|
+
# puts " view = #{view}"
|
574
|
+
# end
|
575
|
+
#
|
576
|
+
# @param [Integer] flags
|
577
|
+
# A bit mask that tells the state of the modifier
|
578
|
+
# keys and other mouse buttons at the time.
|
579
|
+
#
|
580
|
+
# @param [Integer] x
|
581
|
+
# The X coordinate on the screen where the event occurred.
|
582
|
+
#
|
583
|
+
# @param [Integer] y
|
584
|
+
# The Y coordinate on the screen where the event occurred.
|
585
|
+
#
|
586
|
+
# @param [Sketchup::View] view
|
587
|
+
#
|
588
|
+
# @version SketchUp 6.0
|
589
|
+
def onMouseMove(flags, x, y, view)
|
590
|
+
end
|
591
|
+
|
592
|
+
# The #{onMouseWheel} method is called by SketchUp when the mouse scroll wheel
|
593
|
+
# is used.
|
594
|
+
#
|
595
|
+
# @example
|
596
|
+
# class ExampleTool
|
597
|
+
#
|
598
|
+
# def initialize
|
599
|
+
# @property_value = 0
|
600
|
+
# @rect = [
|
601
|
+
# Geom::Point3d.new(100, 150, 0),
|
602
|
+
# Geom::Point3d.new(300, 150, 0),
|
603
|
+
# Geom::Point3d.new(300, 250, 0),
|
604
|
+
# Geom::Point3d.new(100, 250, 0),
|
605
|
+
# ]
|
606
|
+
# end
|
607
|
+
#
|
608
|
+
# def onMouseMove(flags, x, y, view)
|
609
|
+
# view.invalidate
|
610
|
+
# end
|
611
|
+
#
|
612
|
+
# def onMouseWheel(flags, delta, x, y, view)
|
613
|
+
# # If the cursor is not within the bounds of the rectangle, return false
|
614
|
+
# # to let SketchUp do its default action (zoom).
|
615
|
+
# point = Geom::Point3d.new(x, y)
|
616
|
+
# return false unless Geom.point_in_polygon_2D(point, @rect, true)
|
617
|
+
#
|
618
|
+
# # If cursor is within the bounds of the rectangle, update the value
|
619
|
+
# # and prevent the default zoom.
|
620
|
+
# @property_value += delta
|
621
|
+
# view.invalidate
|
622
|
+
# true
|
623
|
+
# end
|
624
|
+
#
|
625
|
+
# def draw(view)
|
626
|
+
# view.line_width = 2
|
627
|
+
# view.line_stipple = ''
|
628
|
+
# view.drawing_color = 'red'
|
629
|
+
# view.draw2d(GL_QUADS, @rect)
|
630
|
+
#
|
631
|
+
# point = Geom::Point3d.new(120, 170)
|
632
|
+
# view.draw_text(point, "Value: #{@property_value}",
|
633
|
+
# size: 20, bold: true, color: 'black')
|
634
|
+
# end
|
635
|
+
#
|
636
|
+
# end
|
637
|
+
#
|
638
|
+
# Sketchup.active_model.select_tool(ExampleTool.new)
|
639
|
+
#
|
640
|
+
# @param [Integer] flags
|
641
|
+
# A bit mask that tells the state of the modifier
|
642
|
+
# keys and other mouse buttons at the time.
|
643
|
+
#
|
644
|
+
# @param [Integer] delta
|
645
|
+
# Either +1+ or +-1+ depending on which direction the
|
646
|
+
# mouse wheel scrolled.
|
647
|
+
#
|
648
|
+
# @param [Float] x
|
649
|
+
# The X coordinate on the screen where the event occurred.
|
650
|
+
#
|
651
|
+
# @param [Float] y
|
652
|
+
# The Y coordinate on the screen where the event occurred.
|
653
|
+
#
|
654
|
+
# @param [Sketchup::View] view
|
655
|
+
#
|
656
|
+
# @return [Boolean] Return +true+ to prevent SketchUp from performing default
|
657
|
+
# zoom action.
|
658
|
+
#
|
659
|
+
# @version SketchUp 2019.2
|
660
|
+
def onMouseWheel(flags, delta, x, y, view)
|
661
|
+
end
|
662
|
+
|
663
|
+
# The #{onRButtonDoubleClick} is called by SketchUp when the user double clicks
|
664
|
+
# with the right mouse button.
|
665
|
+
#
|
666
|
+
# @example
|
667
|
+
# def onRButtonDoubleClick(flags, x, y, view)
|
668
|
+
# puts "onRButtonDoubleClick: flags = #{flags}"
|
669
|
+
# puts " x = #{x}"
|
670
|
+
# puts " y = #{y}"
|
671
|
+
# puts " view = #{view}"
|
672
|
+
# end
|
673
|
+
#
|
674
|
+
# @param [Integer] flags
|
675
|
+
# A bit mask that tells the state of the modifier
|
676
|
+
# keys and other mouse buttons at the time.
|
677
|
+
#
|
678
|
+
# @param [Integer] x
|
679
|
+
# The X coordinate on the screen where the event occurred.
|
680
|
+
#
|
681
|
+
# @param [Integer] y
|
682
|
+
# The Y coordinate on the screen where the event occurred.
|
683
|
+
#
|
684
|
+
# @param [Sketchup::View] view
|
685
|
+
#
|
686
|
+
# @version SketchUp 6.0
|
687
|
+
def onRButtonDoubleClick(flags, x, y, view)
|
688
|
+
end
|
689
|
+
|
690
|
+
# The #{onRButtonDown} method is called by SketchUp when the user presses
|
691
|
+
# the right mouse button. Implement this method, along with the tool.getMenu
|
692
|
+
# method, when you want your tool to do something other than display the
|
693
|
+
# default context menu when the right mouse button is clicked.
|
694
|
+
#
|
695
|
+
# @example
|
696
|
+
# def onRButtonDown(flags, x, y, view)
|
697
|
+
# puts "onRButtonDown: flags = #{flags}"
|
698
|
+
# puts " x = #{x}"
|
699
|
+
# puts " y = #{y}"
|
700
|
+
# puts " view = #{view}"
|
701
|
+
# end
|
702
|
+
#
|
703
|
+
# @param [Integer] flags
|
704
|
+
# A bit mask that tells the state of the modifier
|
705
|
+
# keys and other mouse buttons at the time.
|
706
|
+
#
|
707
|
+
# @param [Integer] x
|
708
|
+
# The X coordinate on the screen where the event occurred.
|
709
|
+
#
|
710
|
+
# @param [Integer] y
|
711
|
+
# The Y coordinate on the screen where the event occurred.
|
712
|
+
#
|
713
|
+
# @param [Sketchup::View] view
|
714
|
+
#
|
715
|
+
# @version SketchUp 6.0
|
716
|
+
def onRButtonDown(flags, x, y, view)
|
717
|
+
end
|
718
|
+
|
719
|
+
# The #{onRButtonUp} method is called by SketchUp when the user releases the
|
720
|
+
# right mouse button.
|
721
|
+
#
|
722
|
+
# @example
|
723
|
+
# def onRButtonUp(flags, x, y, view)
|
724
|
+
# puts "onRButtonUp: flags = #{flags}"
|
725
|
+
# puts " x = #{x}"
|
726
|
+
# puts " y = #{y}"
|
727
|
+
# puts " view = #{view}"
|
728
|
+
# end
|
729
|
+
#
|
730
|
+
# @param [Integer] flags
|
731
|
+
# A bit mask that tells the state of the modifier
|
732
|
+
# keys and other mouse buttons at the time.
|
733
|
+
#
|
734
|
+
# @param [Integer] x
|
735
|
+
# The X coordinate on the screen where the event occurred.
|
736
|
+
#
|
737
|
+
# @param [Integer] y
|
738
|
+
# The Y coordinate on the screen where the event occurred.
|
739
|
+
#
|
740
|
+
# @param [Sketchup::View] view
|
741
|
+
#
|
742
|
+
# @version SketchUp 6.0
|
743
|
+
def onRButtonUp(flags, x, y, view)
|
744
|
+
end
|
745
|
+
|
746
|
+
# The {#onReturn} method is called by SketchUp when the user hit the Return key
|
747
|
+
# to complete an operation in the tool. This method will rarely need to be
|
748
|
+
# implemented.
|
749
|
+
#
|
750
|
+
# @example
|
751
|
+
# def onReturn(view)
|
752
|
+
# puts "onReturn(#{view})"
|
753
|
+
# end
|
754
|
+
#
|
755
|
+
# @param [Sketchup::View] view
|
756
|
+
#
|
757
|
+
# @return [nil]
|
758
|
+
#
|
759
|
+
# @version SketchUp 6.0
|
760
|
+
def onReturn(view)
|
761
|
+
end
|
762
|
+
|
763
|
+
# The #{onSetCursor} method is called by SketchUp when the tool wants to set
|
764
|
+
# the cursor.
|
765
|
+
#
|
766
|
+
# @example
|
767
|
+
# def onSetCursor
|
768
|
+
# puts "onSetCursor: view = #{view}"
|
769
|
+
# # You would set your cursor here. See UI.set_cursor method.
|
770
|
+
# UI.set_cursor(@cursor_id) # UI.set_cursor return true
|
771
|
+
# end
|
772
|
+
#
|
773
|
+
# @return [Boolean] Return +true+ to prevent SketchUp using the default cursor.
|
774
|
+
#
|
775
|
+
# @version SketchUp 6.0
|
776
|
+
def onSetCursor
|
777
|
+
end
|
778
|
+
|
779
|
+
# The {#onUserText} method is called by SketchUp when the user has typed text
|
780
|
+
# into the VCB and hit return.
|
781
|
+
#
|
782
|
+
# @example
|
783
|
+
# def onUserText(text, view)
|
784
|
+
# @distance = text.to_l
|
785
|
+
# rescue ArgumentError
|
786
|
+
# view.tooltop = 'Invalid length'
|
787
|
+
# end
|
788
|
+
#
|
789
|
+
# @param [String] text
|
790
|
+
# The text string that was typed into the VCB.
|
791
|
+
#
|
792
|
+
# @param [Sketchup::View] view
|
793
|
+
# A view object where the method was invoked.
|
794
|
+
#
|
795
|
+
# @version SketchUp 6.0
|
796
|
+
def onUserText(text, view)
|
797
|
+
end
|
798
|
+
|
799
|
+
# The #{resume} method is called by SketchUp when the tool becomes active again
|
800
|
+
# after being suspended.
|
801
|
+
#
|
802
|
+
# @example
|
803
|
+
# def resume(view)
|
804
|
+
# puts "resume: view = #{view}"
|
805
|
+
# end
|
806
|
+
#
|
807
|
+
# @param [Sketchup::View] view
|
808
|
+
#
|
809
|
+
# @version SketchUp 6.0
|
810
|
+
def resume(view)
|
811
|
+
end
|
812
|
+
|
813
|
+
# The #{suspend} method is called by SketchUp when the tool temporarily becomes
|
814
|
+
# inactive because another tool has been activated. This typically happens
|
815
|
+
# when a viewing tool is activated, such as when orbit is active due to the
|
816
|
+
# middle mouse button.
|
817
|
+
#
|
818
|
+
# @example
|
819
|
+
# def suspend(view)
|
820
|
+
# puts "suspend: view = #{view}"
|
821
|
+
# end
|
822
|
+
#
|
823
|
+
# @param [Sketchup::View] view
|
824
|
+
#
|
825
|
+
# @version SketchUp 6.0
|
826
|
+
def suspend(view)
|
827
|
+
end
|
828
|
+
|
829
|
+
end
|