Bug? [Not a Bug - Intentional] Example Code for MenuItems.AddAll throws error.

LWGShane

Well-Known Member
Licensed User
Longtime User
Error: "String can't be cast to MenuItem"

Code:
B4X:
FileMenu.MenuItems.AddAll(Array As String("New Project"))
 

stevel05

Expert
Licensed User
Longtime User
Which example code are you referring to?
 

LWGShane

Well-Known Member
Licensed User
Longtime User
Which example code are you referring to?
When you type "Menu.MenuItems.AddAll", the example in the popup:

B4X:
List.AddAll(Array As String("value1", "value2"))
However, when you actually use "Array As String()" inside the "AddAll" function it says "String can't be cast to MenuItem".
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is not a bug.

MenuBar.Menus returns a regular List.
When you write MenuBar.Menus.AddAll the IDE shows you the documentation of List.AddAll.

There are many advantages for providing access to a List instead of adding methods such as:
MenuBar.AddMenuItem(...)
MenuBar.Remove(...)

The downside is that you do see the documentation of a regular List.
 

LWGShane

Well-Known Member
Licensed User
Longtime User
@Erel - Oh alright. Good to know that it's intentional. You can lock this thread.
 
Top