Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
DavJans
- Posts: 275
- Joined: Thu Dec 12, 2013 4:21 pm
Post
by DavJans » Wed Apr 04, 2018 8:35 pm
Is there a way to do something like this?
Code: Select all
set the backgroundcolor of all the buttons in group "group1"
Thank you
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
-
Klaus
- Posts: 14198
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Wed Apr 04, 2018 8:48 pm
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
-
DavJans
- Posts: 275
- Joined: Thu Dec 12, 2013 4:21 pm
Post
by DavJans » Wed Apr 04, 2018 8:58 pm
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.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
-
DavJans
- Posts: 275
- Joined: Thu Dec 12, 2013 4:21 pm
Post
by DavJans » Wed Apr 04, 2018 9:12 pm
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
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
-
Klaus
- Posts: 14198
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Wed Apr 04, 2018 9:38 pm
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
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10324
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Wed Apr 04, 2018 10:19 pm
Works for me as well.
The error indicates perhaps that you have misnamed the group?
Craig Newman
-
bogs
- Posts: 5480
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Wed Apr 04, 2018 10:28 pm
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).
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10324
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Thu Apr 05, 2018 3:13 am
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
-
bogs
- Posts: 5480
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Thu Apr 05, 2018 5:17 am
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

-
DavJans
- Posts: 275
- Joined: Thu Dec 12, 2013 4:21 pm
Post
by DavJans » Thu Apr 05, 2018 3:25 pm
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.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10324
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Thu Apr 05, 2018 5:23 pm
Bogs.
One might say this was a lemon.
I so love spell check.
Craig
-
bogs
- Posts: 5480
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Thu Apr 05, 2018 7:36 pm
I wouldn't change it for the world, it makes life humorous
