I did some searching through the forum and found some code for enabling/disabling textfields, but there seem to be some deprecated calls in it.
I want to loop through and clear out the text from my WebTextFields. Those WebTextFields are in a couple different WebRectangles I’m using as control groups (there are various controls in each, not just WebTextFields.
Here’s what I’ve got:
//HomePage is the page I'm working with
//InfoContainer1 is a WebContainer I've imbedded in HomePage
Var i As Integer
Var c As myTextField //Custom WebTextField I've added some properties to
for i = 0 to HomePage.InfoContainer1.LastControlIndex
if HomePage.InfoContainer1.ControlAt(i) isa myTextField then
c = StudentPageTextField(self.ControlAt(i))
c.Text=""
end if
Next
The good news is that it doesn’t crash anything . . . The bad news is that it also doesn’t seem to do anything. If I put in a message box with i it doesn’t give the right number of controls.
Suggestions? Better solutions? (I mean, any solution is a better solution LOL)
That ALMOST does it. I didn’t show in the code, but I’ve got controls grouped in a WebRectangle. I can the MyTextFields in the WebContainer, but when I go one deeper HomePage.InfoContainer1.MyControlsAreInThisWebRectangle.ControlAt(i) isa myTextField
then it doesn’t seem to find them at all (if I do a message with i’s value it’s -1).
Thank for that. I was just going over this again this morning, as it’s annoying me to no end.
As MarkusR pointed out I had some sloppy coding (mostly because instead of just copy/pasting I tried to make it more generic for easier reading), and that solved the problem as long as it’s not in an embedded control.
I opened a new web project, subclassed WebTextField to MyWebTextField (which was probably unnecessary, but whatever), put a few MyWebTextFields into the main webpage and put the following into a PushButton:
Var i As Integer
Var c As myWebTextField //Custom WebTextField I've added some properties to
for i = 0 to self.LastControlIndex
if self.ControlAt(i) isa myWebTextField then
c = myWebTextField(self.ControlAt(i))
c.Text="Hi"
end if
Next
That works without a hitch.
If I add a WebRectangle (Rectangle1), add some MyWebTextFields to that and try to do the same thing:
Var j As Integer
Var d As myWebTextField //Custom WebTextField I've added some properties to
for j = 0 to Rectangle1.LastControlIndex
if Rectangle1.ControlAt(j) isa myWebTextField then
d = myWebTextField(Rectangle1.ControlAt(j))
d.Text="I'm Inside the Rectangle"
end if
Next
It no longer works.
For now, thank you MarkusR for steering me back in the right direction, and thank you, Jeannot for pointing me to the Feedback case. Looks like another “Be patient and wait for a fix” scenario.
Most likely yes but again I’m not sure. I just stopped using them as Xojo confirms that it is reproducible. This hurts and I’m impatient but I won’t waste my time until it is fixed :-).