Group objects "Lessons Learned" & question
Posted: Tue Mar 28, 2017 4:38 pm
I bring items to the forum for 2 reasons: 1. to get answers/advice from more experienced users and 2 . to expose other users to problems that I am having with LiveCode.
Call this "Lessons Learned"
I have been working with Group Objects as of late. I thought I was having good experiences using code that would discover the fields in groups and low and behold I fell into a Rabbit hole and everything went to hell.
this is an example of some of the code:
repeat with xfield = 1 to the number of fields in group "grpTest"
set the lockText of field xField to false
put the short name of field xField into tField
end repeat
This code seemed to work just fine and I was actually able to loop through legitimate fields in my group. But, The idea was to loop through only the fields that are contained in the group and ignore other objects on the card. I only included the fields and not the labels. BUT, as I added other groups onto the card, things got hinky. The code seemed to have lost focus on the named Group and started looking at all of the fields on the card. This was fairly frustrating and required many hours of trying remedy the situation. I tried and re-tried to re-code and exam what was happening. I removed and replaced, renamed groups and everything that I could think of. No such luck. Other weird anomalies were happening also - I seemed to have lost the ability to capture the "On MouseUp" commands and had to use the "right click" of my mouse to make a "MouseUp" command.
Finally I was forced to the LiveCode dictionary to see what was happening.
I discovered the "the ChildControlName" command. I had to use a little more of a verbose script to do the same thing but it worked.
Sample Code:
put the childControlNames of group "Test" into grList
# ENABLE PROJECT INFORMATION GROUP
# ALL FIELDS ARE DEFAULTED TO LOCKTEXT IS TRUE
repeat with xfield = 1 to the number of lines of grList
put line xfield of grList into tField
set the lockText of field tField to false
set the foreGroundColor of field tField to "red"
end repeat
This works just the way I wanted it to do.
So, Question:
Has anyone used the first bit of code :"repeat with xfield = 1 to the number of fields in group "grpTest" or similar with any success? Especially with multiple groups on a card. I was obviously wrong with my assumptions of how this was to work - or is this a bug in LiveCode that needs to be placed in a bug report? I know that Groups with Nested Groups can throw the message path for a loop. But this is not a nested group.
Any comments or recommendations would greatly be appreciated. If not for myself but for the education of other LiveCoders out there.
Call this "Lessons Learned"
I have been working with Group Objects as of late. I thought I was having good experiences using code that would discover the fields in groups and low and behold I fell into a Rabbit hole and everything went to hell.
this is an example of some of the code:
repeat with xfield = 1 to the number of fields in group "grpTest"
set the lockText of field xField to false
put the short name of field xField into tField
end repeat
This code seemed to work just fine and I was actually able to loop through legitimate fields in my group. But, The idea was to loop through only the fields that are contained in the group and ignore other objects on the card. I only included the fields and not the labels. BUT, as I added other groups onto the card, things got hinky. The code seemed to have lost focus on the named Group and started looking at all of the fields on the card. This was fairly frustrating and required many hours of trying remedy the situation. I tried and re-tried to re-code and exam what was happening. I removed and replaced, renamed groups and everything that I could think of. No such luck. Other weird anomalies were happening also - I seemed to have lost the ability to capture the "On MouseUp" commands and had to use the "right click" of my mouse to make a "MouseUp" command.
Finally I was forced to the LiveCode dictionary to see what was happening.
I discovered the "the ChildControlName" command. I had to use a little more of a verbose script to do the same thing but it worked.
Sample Code:
put the childControlNames of group "Test" into grList
# ENABLE PROJECT INFORMATION GROUP
# ALL FIELDS ARE DEFAULTED TO LOCKTEXT IS TRUE
repeat with xfield = 1 to the number of lines of grList
put line xfield of grList into tField
set the lockText of field tField to false
set the foreGroundColor of field tField to "red"
end repeat
This works just the way I wanted it to do.
So, Question:
Has anyone used the first bit of code :"repeat with xfield = 1 to the number of fields in group "grpTest" or similar with any success? Especially with multiple groups on a card. I was obviously wrong with my assumptions of how this was to work - or is this a bug in LiveCode that needs to be placed in a bug report? I know that Groups with Nested Groups can throw the message path for a loop. But this is not a nested group.
Any comments or recommendations would greatly be appreciated. If not for myself but for the education of other LiveCoders out there.