MenuItem.visible=false

On the main menu I have FILE -> Recent Files -> menuDB(10) where menuDB is a “control array” of 10 menu place holders

Under the EnableMenuItems I have code like this

x=ubound(MRU_DB_FILES) // array of 0 to x FolderItems, only care about 1st 10 or less
For i=0 To 9
If i<=x Then 
menuDB(i).Visible=True
menuDB(i).Text=MRU_DB_Files(i).folderPath.DisplayName
Else
menuDB(i).Visible=False
menuDB(i).Text="?X" // added as a test
End If
Next i

This code works PERFECTLY on macOS, but under windows, while the VISIBLE line executes, the menu item STAYS visible

Is this a bug in Xojo? an issue with Windows? is there a workaround?

EDIT> I see this is “NOT SUPPORTED BY WINDOWS” … any ideas on a workaround?

MenuItem.Visible:

This property is only available on macOS and Linux platforms.

The list is dynamic… so it may go from 9 items to 5 items during program execution… so I cannot prepopluate the menu

Start with menuDB(0) only. Then add menuitems dynamically. When you need to rebuild the menu, remove all but menuDB(0) and start again.

where one or two items need to be hidden, I sometimes change the text to “-” and it becomes a separator

The only problem is you need to manually keep track of the number of items that exists. since their is no UBOUND

Wouldn’t that be Ubound(MRU_DB_FILES)?

“remove all but menuDB(0)”. There is no way to know how many more there are… I can’t use MRU_DB_FILE.UBOUND because it may or may not have had items removed. The issue is when the number of items in MRU_DB_FILE does not match the number of items in menuDB. Either items need to be appended to menuDB (not an issue)… .Or some unknown number need to be removed.

MRU_DB_FILE could lose items during the course of the program running (ie. the user decides to delete one or more files)