WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   multiple sliders (https://forum.worldviz.com/showthread.php?t=4312)

jaclyn.bill 07-30-2012 04:59 AM

multiple sliders
 
Hello,

Hopeing there is a simple answer this this, but how do you distinguish between four sliders so that each slider alters a separate parameter.

I have 4 sliders sliderSWRD, sliderSWEX, sliderRTRD, sliderRTEX set at the four corners of my screen. When I use the follwing code to detect a response from say SWRD and change a parameter it works fine; however, responding with any of the other sliders also changes that parameter and I don't want this to happen.

HTML Code:

def reponse():
        global radadj, radius, adjustswing, swingmiddle
        def myslider(sliderSWRD, pos):
                adjustswing=swingmiddle-pos
                def onMouseDown(button):
                        if button == viz.MOUSEBUTTON_RIGHT:
                                radius=radius+adjustswing
                                sliderSWRD.disable()  ### re-enabled elsewhere
                viz.callback(viz.MOUSEDOWN_EVENT,onMouseDown)
        viz.callback(viz.SLIDER_EVENT,myslider)

Any tips would be useful, sure I'm missing something obvious. Thank you.

Jeff 07-30-2012 08:55 PM

You need to check that the slider object passed to the callback function is sliderSWRD before changing that parameter:
Code:

def onSlider(obj,pos):
    if obj == sliderSWRD:
        #change parameter

viz.callback(viz.SLIDER_EVENT,onSlider)

You can also use the vizact.onslider command to call different callback functions based on which slider was changed:
Code:

def onSliderSWRD(pos):
        #do something
       
vizact.onslider(sliderSWRD,onSliderSWRD)

def onSliderSWEX(pos):
        #do something
       
vizact.onslider(sliderSWEX,onSliderSWEX)


jaclyn.bill 08-01-2012 01:20 AM

Excellent :) Thank you very much.

Jac


All times are GMT -7. The time now is 08:14 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC