A pickbutton control is used to place a scene object-picker button on the rollout. It operates like a normal pick button in the 3ds Max user interface, turning light-green when pressed and causing an object-pick mode to be entered. The user can then choose a scene object by clicking on it. The pick mode exits and the button returns to its unpressed state. The user can right-click to cancel the pick mode.
The syntax is:
pickbutton <name> [<caption>] [message:<string>] [filter:<function>] [toolTip:<string>] [autoDisplay:<boolean>]
The default alignment of pickbutton
items is #center
.
EXAMPLE:
rollout pick_box_test "Pick Box Test" ( --filter all objects of class Box: fn box_filt obj = classof obj == Box --Pickbutton to select a Box from the scene pickbutton chooseit "Select Box" width:140 filter:box_filt --If the user picked an object, then on chooseit picked obj do ( --see if the user did not cancel the picking... if obj != undefined do ( --if he did not, make the box's wireframe red: obj.wirecolor = red --and display the name of the object on the button: chooseit.text = obj.name ) )--end on )--end rollout createDialog pick_box_test
Note that the filter function will not let you select any other objects except Boxes.
Parameters:
message:
The optional text to be displayed in the 3ds Max status line while in the pick mode. Default is no message.
filter:
The optional filter function that will be called to test the eligibility of the scene object under the cursor for picking. It must be a function of one argument, which will be the object under test, and return true
if the object is eligible or false
if not.
Default is no filtering.
EXAMPLE:
The following filter function allows only objects whose names begin with "foo" to be pickable:
fn foo_filter obj = matchPattern obj.name pattern:"foo*"
toolTip:
Provides text for a tooltip for the button. No tooltip if unsupplied.
autoDisplay:
When set to true
, the name of the picked object will be automatically displayed as the text on the button. If false
or not specified, the button caption will not be changed.
Properties
<pickbutton>.object Node
The last object picked using the pickbutton
, undefined
if no object has been picked. The property can be both get and set, accepting a node or undefined.
<pickbutton>.tooltip String
Get/set the tooltip string of the checkbutton.
Available in 3ds Max 9 and higher.
EXAMPLE:
--If you pick a scene object, the tooltip of the pickbutton will show --the name of the object you picked. rollout test "Test" ( pickbutton pck_test ">>Pick An Object" tooltip:"Pick A Scene Object..." on pck_test picked obj do if isValidNode obj do pck_test.tooltip = "You picked " + obj.name ) createDialog test
Events:
on <pickbutton> picked <arg> do <expr>
Called when the user selects an object in the scene while in the pickbutton
pick mode. The <arg>
argument will contain the selected object. The handler is not called if the user cancels out of the pick mode.
on <pickbutton> rightclick do <expr>
Called when the right mouse button is released over the button. Available in 3ds Max 8 and higher.