Ok, I have 3 states that a variable could be in. 1, 0, -1.
Based on the state I want to set the LeftMouseDownAction of an Image Meter. I am assuming that I want to use ifabovevalue, ifbelowvalue, and ifequalvalue, but I am not sure how to implement it properly.
I have done some searching, but I am not sure.
Can you point me in the right direction?
It is currently April 30th, 2024, 8:37 am
Select Case
-
- Posts: 13
- Joined: December 22nd, 2012, 6:00 pm
-
- Developer
- Posts: 1721
- Joined: July 25th, 2009, 4:47 am
Re: Select Case
Something like this would be the usual approach:
Note that these three cases happen to be exactly the maximum that this approach can handle (since "above," "equal" and "below" are the only conditional options). Here's an alternative approach that would allow any number of cases:
(Also, as a general piece of advice, we usually recommend using LeftMouseUpAction instead of LeftMouseDownAction, since having a "down" trigger interferes with the user's ability to click and drag the skin. You may have different needs for your skin, of course. :)
Code: Select all
[MeasureCase]
Measure=Calc
Formula=#Var#
DynamicVariables=1
; First, if #Var# = 1:
IfAboveValue=0
IfAboveAction=!SetOption ImageMeterName LeftMouseDownAction "..."
; Second, if #Var# = 0:
IfEqualValue=0
IfEqualAction=!SetOption ImageMeterName LeftMouseDownAction "..."
; Third, if #Var# = -1:
IfBelowValue=0
IfBelowAction=!SetOption ImageMeterName LeftMouseDownAction "..."
Code: Select all
[ImageMeterName]
Meter=Image
DynamicVariables=1
MeterStyle=Style#Var#
[Style1]
LeftMouseDownAction=...
[Style0]
LeftMouseDownAction=...
[Style-1]
LeftMouseDownAction=...
-
- Posts: 13
- Joined: December 22nd, 2012, 6:00 pm
Re: Select Case
Oh nice!!! Thank you, that will do the trick nicely.
I definitely concur up is better than down. I was using code from a sample skin I was looking at. Thanks for pointing that out.
I definitely concur up is better than down. I was using code from a sample skin I was looking at. Thanks for pointing that out.