A newer version of Max is available. Click here to access the latest version of this document.

pictslider

Picture-based slider control

Description

The pictslider object is a slider control that uses pictures in external files for its appearance. It uses two pictures--one for the "knob" (the part that you move with the mouse, corresponding to the part of a physical slider that you move with your fingers) and one for the background over which the knob moves. The pictslider object has default pictures that are used if you do not want to supply pictures of your own, but its intended use is creating controls with customized appearances.

You can use the pictslider object to create horizontal or vertical sliders, as well as two-dimensional controllers (virtual trackpads or joysticks).

Note: The pictslider object customarily uses images saved in Portable Network Graphics (.png) format. If you are using Max on Windows, we recommend that you install QuickTime and choose a complete install of all optional components to work with images other than PNG or PICT files.

Arguments

None.

Messages

bang In left inlet: Sends the current values of the pictslider to its outlets. The horizontal value is sent out the left outlet; the vertical value out its right outlet.
int horizontal-value [int]
In left inlet: sets the pictslider object's horizontal value. The value is also sent out the left outlet, and the pictslider object's current vertical value is sent out the right outlet.

In right inlet: sets the pictslider object's vertical value. The value is also sent out the right outlet, and the control's current horizontal value is sent out the left outlet.
float horizontal-value [float]
Converted to int.
list horizontal and vertical values [list]
In left inlet: A list of two numbers sent to the left inlet sets the pictslider object's horizontal value to the first number and its vertical value to the second. The two values are sent out the left and right outlets.
bkgndpicture filename [list]
The word bkgndpicture, followed by a symbol that specifies a filename, designates the graphics file that the pictslider object will use for the control's background image. By convention, the pictslider object uses images saved in Portable Network Graphics (.png) format. If you are using Max on Windows and want to to work with images other than PNG or PICT files, we recommend that you install QuickTime and choose a complete install of all optional components. The symbol used as a filename must either be the name of a file in Max's current search path, or an absolute pathname for the file (e.g. "MyDisk:/Documents/UI Pictures/CoolBkgnd.png").
(drag) When a image file is dragged from the Max 5 File Browser to a pictslider object, the image will be loaded as the object's background image.
knobpicture filename [list]
In left inlet: The word knobpicture, followed by a symbol that specifies a filename, designates the graphics file that the pictslider object will use for the control's knob file. The symbol used as a filename must either be the name of a file in Max's current search path, or an absolute pathname for the file (e.g. "MyDisk:/Documents/UI Pictures/CoolKnob.png"). The word knobpicture by itself puts up a standard Open Document dialog box.
(mouse) Clicking on the pictctrl object and dragging sends the current value out the outlet. Additional behaviors depend on how the object is configured using messagse or setting attributes.
set horizontal and vertical values [list]
In left inlet: The word set, followed by a number, sets the pictcslider object's horizontal value but does not send the value out its left outlet.The word set, followed by two numbers, sets the pictslider object's horizontal value to the first number and its vertical value to the to the second number, but does not send the values out its outlets.

In right inlet: The word set, followed by a number, sets the pictslider object's vertical value, but does not send the value out its right outlet.
readanybkgnd filename [list]
The word readanybkgnd followed by the name of a file will read any type of file into the pictslider object and attempt to interpret it as a background image.
readanyknob filename [list]
The word readanyknob followed by the name of a file will read any type of file into the pictslider object and attempt to interpret it as a knob image.
track horizontal/vertical-tracking-ratio [float]
In left inlet: The word track, followed by a float, sets the tracking ratio for horizontal movements of the pictslider object's knob.

In right inlet: The word track, followed by a float, sets the tracking ratio for vertical movements of the pictslider object's knob.

Attributes

Name Type g/s Description
active int
def.:1
Toggles mouse control of the pictslider object. The default is 1 (enabled). If a separate set of inactive images is present in the pictslider object's graphics file and if the inactive images attribute is set, the active message will also change the appearance of the control.
bkgnddrag int
def.:0
Toggles background drag mode for the pictslider object. When this mode is enabled, clicking and dragging anywhere in the background area of the slider will move the knob; the knob will move relative to the motion of the mouse, just as if you had clicked in the knob itself. The message bkgnddrag 0 disables this mode. You must also uncheck the KnobJumps to Click Location checkbox in the pictslider object's Inspector or send the object a jump 0 message to enable this mode.
bkgndpict symbol
def.:<default>
Designates the graphics file that the pictslider object will use for the control's background image. The symbol used as a filename must either be the name of a file in Max's current search path, or an absolute pathname for the file (e.g. "MyDisk:/Documents/UI Pictures/CoolBkgnd.png").
bkgndsize int
def.:0
Sets the pictslider object to change the size of the object to match the size of the background picture. After receiving this message, the object's size cannot be changed. bkgndsize 0 allows the control to be resized in the usual manner by dragging its lower-right corner.
bottommargin int
def.:0
Sets the bottom margin, in pixels, for the pictslider. The margin reduces the area in which the knob moves; if a margin is zero, the knob can move all the way to the bottom of the slider.
bottomvalue int
def.:0
Sets the values emitted by the pictslider object when the knob is moved as far as possible to the bottom. The message bottomvalue 100 will cause the control to send 100 out of its left outlet when the knob is moved all the way to the bottom.
clickedimage int
def.:1
Specifies that the graphics file used by the pictslider object contains an additional image to be displayed when the control is clicked.
horizontaltracking float
def.:1.
Sets the horizontal tracking ratio for movements of the pictslider object's knob. The default value is 1.0. Values greater than one cause the knob to move more quickly when dragged; values less than one cause it to move more slowly.
imagemask int
def.:0
When set to 1, specifies that the graphics file used by the pictslider object contains image masks. This attribute is present for legacy support - it has been superseded by the use of alpha channels in images.
inactiveimage int
def.:1
When set to non-zero, specifies that the graphics file used by the pictslider object contains additional images for the object's inactive state.
invisiblebkgnd int
def.:0
When set to non-zero, the pictslider object will not draw any background image. The knob will appear to float above any objects underneath it.
jump int
def.:1
When set to non-zero, makes pictslider move the knob to the position of the cursor if you click in the object outside of the knob. jump 0 disables this behavior; you must click in the knob itself to move it.
knobpict symbol
def.:<default>
Designates the graphics file that the pictslider object will use for the control's knob image. By convention, the pictslider object uses images saved in Portable Network Graphics (.png) format. If you are using Max on Windows and want to to work with images other than PNG or PICT files, we recommend that you install QuickTime and choose a complete install of all optional components. The symbol used as a filename must either be the name of a file in Max's current search path, or an absolute pathname for the file (e.g. "MyDisk:/Documents/UI Pictures/CoolKnob.png").
leftmargin int
def.:0
Sets the left margin, in pixels, for the pictslider. The margin reduces the area in which the knob moves; if a margin is zero, the knob can move all the way to the left of the slider.
leftvalue int
def.:0
Sets the values emitted by the pictslider object when the knob is moved as far as possible to the left. The message leftvalue 100 will cause the control to send 100 out of its left outlet when the knob is moved all the way to the left.
movehorizontal int
def.:1
When set to non-zero, allows the knob to change when the mouse is moved horizontally. The message movehorizontal 0 prevents the knob from moving when the mouse is moved horizontally.
movevertical int
def.:1
When set to non-zero, allows the knob to change when the mouse is moved vertically. The message movevertical 0 prevents the knob from moving when the mouse is moved vertically.
rightmargin int
def.:0
Sets the right margin, in pixels, for the pictslider. The margin reduces the area in which the knob moves; if a margin is zero, the knob can move all the way to the right of the slider.
rightvalue int
def.:127
Sets the values emitted by the pictslider object when the knob is moved as far as possible to the right. The message rightvalue 100 will cause the control to send 100 out of its left outlet when the knob is moved all the way to the right.
scaleknob int
def.:0
When set to non-zero, tells the pictslider object to stretch or shrink the knob when you change the size of the entire object. scaleknob 0 will result in the knob always being drawn at its original size.
topmargin int
def.:0
Sets the top margin, in pixels, for the pictslider. The margin reduces the area in which the knob moves; if a margin is zero, the knob can move all the way to the top of the slider.
topvalue int
def.:127
Sets the values emitted by the pictslider object when the knob is moved as far as possible to the top. The message topvalue 100 will cause the control to send 100 out of its left outlet when the knob is moved all the way to the top.
verticaltracking float
def.:1.
Sets the vertical tracking ratio for movements of the pictslider object's knob. The default value is 1.0. Values greater than one cause the knob to move more quickly when dragged; values less than one cause it to move more slowly.

Information for box attributes common to all objects

Picture File Format

Specifications: The pictslider object uses the two picture files: one for the background, and one for the knob that is moved over the background with the mouse.

Background picture files can be in PICT format, or if QuickTime Version 3.0 or later is installed, one of the other graphics file formats listed in the QuickTime appendix. Background picture files must have the following layout:



Only one image is required; if only one image is supplied, it will be used for drawing all states of the background. Additional images are placed to the right of the first image. You can add images for the inactive state of the control. The inactive image will be used after the control has received an active 0 message.

Knob files must be in PICT format with the following layout:



The picture is made up of a grid of one or more images. All images have the same width and height.

Only one image is required; if only one image is supplied, it will be used for drawing all states of the knob. Additional images are placed to the right of the first image. You can add images for either or both the "clicked" or inactive states of the control. The "clicked" image will be shown when the user is dragging the control's knob. The inactive image will be used after the control has received an active 0 message.

Image masks can be used to create knobs with non-rectangular outlines. These masks are directly below their corresponding images in the picture file. If you wish to use masks for any of the knob images, you must provide masks for all of them--each image will have a corresponding row of masks. Black pixels in the mask image create areas of the corresponding image that will be drawn, and white pixels create invisible areas.

Output

int: Moving the slider's knob by clicking and dragging it with the mouse, or sending values to either of its inlets, causes its horizontal value to be emitted from the left outlet and its vertical value to be emitted from the right outlet. Incoming values are constrained to the ranges determined by the top/bottom and left/right values set in the inspector.

Examples

pictslider lets you create both one- and two-dimensional UI elements

See Also

Name Description
dial Output numbers by moving a dial onscreen
kslider Output numbers from a keyboard onscreen
multislider Multiple slider and scrolling display
nslider Output numbers from a notation display onscreen
pictctrl Picture-based control
rslider Display or change a range of numbers
slider Output numbers by moving a slider onscreen
tab A user interface tab/multiple button object
textbutton A user interface button/toggle
ubutton Transparent button, sends a bang
Max Basic Tutorial 14: Encapsulation Max Basic Tutorial 14: Encapsulation
Max Interface Tutorial 2: Picture UI Elements Max Interface Tutorial 2: Picture UI Elements