Page 1 of 1
Changing property of grouped buttons
Posted: Wed Apr 04, 2018 8:35 pm
by DavJans
Is there a way to do something like this?
Code: Select all
set the backgroundcolor of all the buttons in group "group1"
Thank you
Re: Changing property of grouped buttons
Posted: Wed Apr 04, 2018 8:48 pm
by Klaus
Hi DavJans,
sure, but you have to use a repeat loop:
Code: Select all
...
repeat with i = 1 to the num of btns of grp "group1"
set the backgroundcolor of btn i of grp "group1" to 1,2,3
end repeat
...
OTOH, if you set the group to non-opaque and the backgroundcolor of the buttons to empty, then you can set the backgroundcolor of the group and the buttons will inherit this property.
Best
Klaus
Re: Changing property of grouped buttons
Posted: Wed Apr 04, 2018 8:58 pm
by DavJans
Thank you Klaus.
The repeat will work.
My problem with setting the backgroundcolor of the group is the buttons are all empty except the one clicked. using the group color doesn't change the color of the last button pushed back to empty.
Re: Changing property of grouped buttons
Posted: Wed Apr 04, 2018 9:12 pm
by DavJans
button"A4": execution error at line 5 (Chunk: can't find background), char 25
What did I do wrong? Is it because I created all the buttons before I grouped them?
Code: Select all
global selLOC
on mouseUp
lock screen
repeat with i = 1 to the num of btns of grp "LOC Group"
set the backgroundcolor of btn i of grp "LOC Group" to empty
set the textcolor of btn i of grp "LOC Group" to empty
end repeat
set the backgroundcolor of me to blue
set the textcolor of me to white
put the label of me into selLOC
unlock screen
end mouseUp
Re: Changing property of grouped buttons
Posted: Wed Apr 04, 2018 9:38 pm
by Klaus
Hm, very strange, just made a test with three grouped buttons and with that above script attached to the first button in the group and it executed without any error!?
I'm using LC 9 on macOS 10.13.4
Re: Changing property of grouped buttons
Posted: Wed Apr 04, 2018 10:19 pm
by dunbarx
Works for me as well.
The error indicates perhaps that you have misnamed the group?
Craig Newman
Re: Changing property of grouped buttons
Posted: Wed Apr 04, 2018 10:28 pm
by bogs
DavJans wrote: ↑Wed Apr 04, 2018 9:12 pm
What did I do wrong? Is it because I created all the buttons before I grouped them?
I suspect Craig is correct, it is probably a name issue. It would not be due to creation order (or shouldn't be, anyway).
Re: Changing property of grouped buttons
Posted: Thu Apr 05, 2018 3:13 am
by dunbarx
To test, just insert a lime that:
Code: Select all
if there is a group "grp "LOC Group" then...
See if the same error comes up.
Craig
Re: Changing property of grouped buttons
Posted: Thu Apr 05, 2018 5:17 am
by bogs
dunbarx wrote: ↑Thu Apr 05, 2018 3:13 am
...just insert a lime that:
<giggling childishly> don't let the 'lime' sour you on the antidote

Re: Changing property of grouped buttons
Posted: Thu Apr 05, 2018 3:25 pm
by DavJans
dunbarx wrote: ↑Wed Apr 04, 2018 10:19 pm
Works for me as well.
The error indicates perhaps that you have misnamed the group?
Craig Newman
Correct. My apologies for wasting all of your time.
Re: Changing property of grouped buttons
Posted: Thu Apr 05, 2018 5:23 pm
by dunbarx
Bogs.
One might say this was a lemon.
I so love spell check.
Craig
Re: Changing property of grouped buttons
Posted: Thu Apr 05, 2018 7:36 pm
by bogs
I wouldn't change it for the world, it makes life humorous
