# Class: Slider

### LuxModule: gui

The slider is a handle than can be moved within some limits.

You can create and use a slider in this way:

     slider = Slider:new(100,20,100,20)
     function slider:onValueChanged (newvalue,oldvalue)
       print(newvalue,oldvalue)
     end
     Container.getRootContainer():add(slider)

The following skinssurface names are used by the slider class:

- Vertical slider skin surfaces
- * sliderv
- * sliderv_pressed
- * sliderv_hovered
- * sliderv_focused
- Horizontal slider skin surfaces
- * sliderh
- * sliderh_pressed
- * sliderh_hovered
- * sliderh_focused

## Hierarchy

    o-+ Component
      o-+ Slider

## Methods:

### Method overview:

- mouseWheeled
- new
- onKeyTyped
- onValueChanged
- setIncrement
- setIntegerMode
- setSliderPos
- setSliderTo
- sliderincrement

new (class, int x,y,w,h, [boolean vertical, [Skin2D, [Icon] ] ])
  returns: (Slider)
  Creates Slider with given bounds. If vertical is true the slider is vertical aligned.
mouseWheeled (Slider,MouseEvent)
  returns: ()
  This function sets the sliderposition if the mousewheel was turned.
onKeyTyped (Slider,KeyEvent)
  returns: ()
  Attached to Slider with a keylistener. Will react on arrow up/down/left/right keypresses and moves the slider.
onValueChanged (Slider, float newvalue,prevvalue)
  returns: ()
  called if the slider position was changed. The values are always between 0 and 1. You can overload this function without calling the original overloaded function. This function is only called if the previous value is distinct from the new value.
setIncrement

  (),(Slider, float inc) - Sets sliderincrement of slider. You could set the value directly by assigning a new value to the sliderincrement value, but you shouldn't chose values <=0 or >1 and you should update the sliderposition to its new value in case that the integermode is on and the value is hereby changed.

setIntegerMode
  (),(Slider, boolean on) - switches IntegerMode on and of. In integermode, the values that are set are being rounded to even multiplies of the sliderincrement value.
setSliderPos (Slider)
  returns: (float pos)
  get the position of the slider 0-1.
setSliderTo (Slider,x,y)
  returns: ()
  sets the slider position nearest to a pixelposition given by x and y that are in local coordinates of the component.
sliderincrement
  {[float]}=0.1 - increment of sliderposition. Can be set per slider. The increment value is used if the mousewheel or the arrow keys have been used.

## Inherited Methods:

### From Component

acceptSkinBounds, addKeyListener, addMouseListener, clipinsets, colors, contains, createVisibles, delete, deleteVisibles, focus, focuscolors, getBounds, getClipRect, getFocusComponentAt, getFocusElement, getFocusIndex, getHeight, getLocation, getMinSize, getMouseLock, getParent, getSize, getSkin, getWidth, getX, getY, hasFocus, hideVisibles, index, invalidate, isClipped, isDisplayedFlag, isFocusable, isMouseLocker, isVisible, isVisibleFlag, keyEvent, keylisteners, local2world, lockMouse, mouseClicked, mouseEntered, mouseEvent, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheeled, mouselisteners, moveToRect, new, newFocusOrder, onDestroy, onDisplayChange, onGainedFocus, onLostFocus, onVisibilityChange, positionUpdate, remove, removeKeyListener, removeMouseListener, setBounds, setClip, setColor, setDisplayable, setFont, setLocation, setSize, setSkin, setVisibility, showVisibles, skinnames.defaultskin, skinnames.focusedskin, skinnames.hoveredskin, skinnames.pressedskin, think, toString, transferFocus, transferFocusOnArrows, transferFocusOnTab, unlockMouse, updateSkin, validate, white, world2local, zorderoffset