PDA

View Full Version : 2 different states in a $


holycause
01-02-2009, 02:16 PM
Hi, I was wondering who i could know if in a $ of 3 obj, a property has a different state.


obj01.xray = true
obj02.xray = false
obj03.xray = true


if i do,

obj01.xray

it will return

true
and if i select all of them and do

$.xray

it returns
-- Unknown property: "xray" in $selection

but if do

$.xray = true

it will change all the xray properties in true

i need to know it because i would like to disable a label if they have a different state

Bobo
01-02-2009, 02:37 PM
Assigning a property one level deep is a MAPPABLE function, so $.xray = true is valid for one or more objects. GETTING a property from more than one object is NOT a mappable function, so you cannot do that. You have to LOOP yourself and check the count of those that have XRAY checked against the count of the selection.

rollout test "Test"
(
checkbox chk_myCheckbox "XRay"
button btn_test "Test"

on btn_test pressed do
(
theCount = (for o in selection where o.xray == true collect o).count
case of
(
(theCount == 0): chk_myCheckbox.triState = 0
(theCount == selection.count): chk_myCheckbox.triState = 1
(theCount < selection.count): chk_myCheckbox.triState = 2
)
)
)
createDialog test

holycause
01-02-2009, 02:54 PM
ok.

thank a lot Bobo ;)

CGTalk Moderation
01-02-2009, 02:54 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.