I’ve encountered something very odd. I am attempting to load and play a YouTube video in a WebHTMLViewer. I have a listbox that is populated with the names of the videos. My thought was to use CellTagAt to populate each video with its respective YouTubeID. When I use CellTagAt and select a video, the app immediately crashes and just shows “Event Loop”
But if I put the YouTubeID in a second column, and call the SelectedRowIndex, it loads and plays just fine
Here’s some of my code:
Populating the WebListbox:
'MySQL connection above this to grab the details
while not rs.AfterLastRow
lbxMovies.AddRow(rs.Column("Name").StringValue)
lbxMovies.CellTagAt(lbxMovies.LastAddedRowIndex, 0) = rs.Column("YouTubeID").StringValue
lbxMovies.CellTextAt(lbxMovies.LastAddedRowIndex, 1) = rs.Column("YouTubeID").StringValue
rs.MoveToNextRow
wend
These next two are in the listbox’s SelectionChanged (one works, one doesn’t):
'This one uses the CellTagAt and throws the Event Loop error
HTMLViewer1.LoadURL("https://www.youtube.com/embed/" + me.CellTagAt(me.SelectedRowIndex, 0) + "?rel=0&autoplay=1")
'This one uses the CellTextAt and looks at the second column
'It works, but this leaves an additional unwanted column in the listbox as WebListBoxes cannot have "hidden" columns
HTMLViewer1.LoadURL("https://www.youtube.com/embed/" + me.CellTextAt(me.SelectedRowIndex, 1) + "?rel=0&autoplay=1")
The funny thing is that I am successfully using CellTagAt in another part of the app to store and get the table’s ID column. I tried this too (storing the ID in the tag and making another call to the db, but the Event Loop error showed)
When you are in the “Event Loop” pause, have you tried pressing the “Run” button (if it’s available)?
I’ve seen times where the hang you’re getting could be resumed that way.
The Resume button is active. Clicking once brings the loop again. Clicking a second time clears the loop, but the video never plays. I am able to select another video from the list, go through the breaks, click resume, and same result unfortunately
For web framework, sometimes when the debugger pauses for seemingly no reason with no editor selected, this can mean that there’s a runtime exception being caught internally. The only way to have these fixed is to open a ticket with a reproducible project.
At this point, I’d inspect the strings (both from CellTag and CellText with the 2nd column). Since your code works using a 2nd column but not using CellTag (even by passing by a variable), and accessing a string from CellTag usually works, I’d expect both strings to have a difference.
The first thing you could try is confirming accessing the CellTag alone doesn’t crash. You’d temporarily comment out the HTMLViewer1.LoadURL statement and replace it by:
Var s as string=me.CellTagAt(me.SelectedRowIndex, 0)
MessageBox s //or break, or nothing
If this also crashes, there’s an issue in simply accessing the tag (which you’d report with a bug report).
If it doesn’t crashes here, you could compare both strings:
Var s as String=me.CellTagAt(me.SelectedRowIndex, 0)
Var t as String=me.CellTextAt(me.SelectedRowIndex, 1)
Break
Carefully inspect and compare s and t (both the content, even as binary, in the IDE, and check that the encoding is correct in both strings).
Thanks guys. I’m taking the weekend off but will build a small test project Monday and submit a feedback if warranted after testing. Will keep you posted
Sadly, something very odd must be happening with my app. I made a small test app and included 4 listboxes all populated with the same 3 videos, YTID, and celltag
listbox1 was loading the video via the second column
listbox2 was loading via calling the CellTagAt directly
listbox3 was loading via calling a string variable that housed the CellTagAt
listbox4 was simply to load the CellTagAt into a string variable and then populate a label
All worked well with no loop crashes. Bummer
Back in my app, I attempted all of the above. The only one which worked was loading the video via the second column. Using CellTagAt crashed with the loop no matter how I did this. I also tried the populating the CellTagAt data into a label as in my listbox4 example in my app, and this worked with no crash
Variables s and t matched up exactly, which was the hopeful expectation, but unfortunately, does not help me find the error
Since I cannot reproduce the error in a test project, I will just have to chalk this up to a ghost in the code somewhere and will have to maintain the second column with the YTIDs. It’s not ideal, but at least it works
I have just encountered the same problem and have discovered that if I populate/apply WeblistBox Column 0 with a WebListBoxStyleRenderer then try and access this text of the cell with “CellTextAt” the error occurs.
(In this case I am applying colour changes to background and text in this cell using WebListBoxStyleRenderer)
Without it applied it works as it should and returns the Text in the cell.
CellTextAt returns a Variant at the moment, that could be either a String or a Cell Renderer. In this case it sounds like you’re receiving a Cell Renderer and you’re trying to cast it into a String.
Something like this could help:
Var cellValue As Variant = YourListBox.CellTextAt(row, column)
Select Case cellValue
Case IsA WebListBoxStyleRenderer
MessageBox(WebListBoxStyleRenderer(cellValue).Value)
Else
MessageBox(cellValue)
End Select
There is already a Feature Request (#73946) to avoid returning a cell renderer in CellTextAt, as it’s misleading.