Page 1 of 1

button reacts on both up and down

Posted: Fri Oct 07, 2005 11:38 pm
by Donleavy
Hey there

I am trying to make a module with a button for the next media and a button for the previous media in the mediasets. The module is pretty simple, but the buttons keep reacting on both down and up. I have set the down value of the button to 1 and the up value to 0, but it doesn't seem to help. The only way I can get it to work is to set the button to "toggle". But it isn't really a toggle button...

What am I doing wrong ?

I upload the module to the public library for you to inspect: Previous+Next

Posted: Sat Oct 08, 2005 12:53 pm
by yves@garagecube
You should check the "param" dictionary sent with the message.

Typically you receive a value in the param, 1.0 for down and 0.0 for up.

For example

Code: Select all

if param['value']==1.0: print 'button is down' elif param['value']==0.0: print 'button is up'
If you want to see the parameter that you receive simply print the param dictionary and check the result in the console:

print param

result for down is:

{'NAME': 'Untitled', 'value': 1.0}

result for up is:

{'NAME': 'Untitled', 'value': 0.0}

NAME is the name of your control.

Posted: Sun Oct 09, 2005 8:54 am
by sigmasix
ok, but what about if we want to deactive the up value (I have the same problem but it doesn't really change my module but that would be better ;))

can we do something like that?

Code: Select all

if param['value']==0.0: param['value']==nil
nil or something similar... I don't know :roll: :wink:

thanks

Posted: Sun Oct 09, 2005 12:22 pm
by yves@garagecube
Not sure what you mean by "deactiving" a value. If you are not interested by the up mouse event you can simply ignore it.

Posted: Sun Oct 09, 2005 2:12 pm
by Donleavy
Thanks for the answer.

I simply put the "if param['value']==1.0:" into my script, and now it works. It looks like this:

Code: Select all

if msg == 'next' : if param['value']==1.0: val = modul8.getValue('ctrl_layer_media',0) newVal = val+1 modul8.setValue('ctrl_layer_media', newVal,0)

/Donleavy

Posted: Sun Oct 09, 2005 10:43 pm
by sigmasix
:P I'm quite stupid :roll: I was thinking in the wrong way... :x :lol: Donleavy just opened my eyes :wink: thanks