I have a PopupMenu that is placed in a container control which I’m embedding via code.
If the container is embedded before items are added to the PopupMenu, then LastAddedRowIndex returns the correct value, but if the items are added before embedding the container, then LastAddedRowIndex is always -1.
I don’t know if it’s “expected” or not, but I’ve run into the same thing with ListBox. Any content added to the control prior to embedding is “lost”, i.e. unavailable after embedding, but no errors are generated.
The pointed behavior makes me think that EmbedWithin works for Containers as kind of New works for Classes, the “instance” happens after its use, and contents are initialized, so changes to instance are only possible after that. The bad news is that Xojo lets changes before that and the silent fails it brings with it “initializing” contents (AGAIN?) with the embedding.
Xojo should see what they can do about to avoid such silent fails.