I'm afraid that I can't see anything wrong with that, unless I am missing something obvious! Maybe its a languange nuance. That methods "gets", that is fetches, the MainMenu from the Form specified and "sets" the value in the MainMenu to what has been "got" (or "gotten" - USIn the help file, the first "GetMainMenu" is meant to be SetMainMenu...
I've posted an updated help in the first post that may explain this library a little more clearly than the original help does.
Sub MenuItem1_Click
TextBox1.Text = "Click : " & [B]MenuItem1.Text [/B]& " : " & MenuItem1.Checked
End Sub
Sub MenuItem1_Popup
Obj1.FromLibrary("NewMenu.MenuItem1", "mitem", B4PObject(2))
Obj1.Value = Obj1.GetProperty("Parent") ' a MainMenu or MenuItem object
parent = obj1.RunMethod("ToString")
If StrIndexOf(parent, "MenuItem", 0) < 0 Then
parent = "Root" ' a MainMenu doesn't have a Text property
Else
parent = Obj1.GetProperty("Text")
End If
TextBox1.Text = parent
End Sub
From the demo
B4X:Sub MenuItem1_Click TextBox1.Text = "Click : " & [B]MenuItem1.Text [/B]& " : " & MenuItem1.Checked End Sub
In the Compact Framework there is no way of identifying individual menu items except by their Text property. They do have a Parent property, not exposed by the library, that is itself a menu item so you could look at the Text property of this with the Door library.
That's what I told you in the first line of my post above!So I added SenderFullName and discovered that there is a name associated with menu items but it is always that of the originating object menuitem1!
I can't disagree but it's a limitation of the Compact Framework. MenuItem objects in the full .NET Framework have a Tag property that can be used to uniquely label them. However the library is intended for use on both desktop and device and so is lower common denominator. You can always use the Door library to access the Tag property on the desktop if necessary.There is a lurking problem behind the use of text rather than name: localisation. Not that I'm going multi-lingual, but it would make identifying menu items that much more complicated.
Just noticed this. Not a good idea! Basic4ppc doesn't cope with removing events from controls so you will probably end up with multiple event sub invocations. You should do something like a CallSub from the event Sub to the code you want to run and get the Sub name from a global, or do a Select.by resetting the click event Sub of each cloned menu to a Sub in the corresponding module
That's what I told you in the first line of my post above!
Just noticed this. Not a good idea! Basic4ppc doesn't cope with removing events from controls so you will probably end up with multiple event sub invocations. You should do something like a CallSub from the event Sub to the code you want to run and get the Sub name from a global, or do a Select.
Oh, well, I guess that the use of CallSub with (yet more) Public Globals is the only way to get what I want.
MainMenuObj.GetMainMenu("Progress.ProgressForm")
MenuItemObj.ControlRef = MainMenuObj.GetMenuItem(0)
MainMenuObj.SaveMenuItem(MenuItemObj.ControlRef, 0)
MainMenuObj.NewMainMenu
MenuItemObj.ControlRef = MainMenuObj.SavedMenuItem(0)
MainMenuObj.AddMenuItem(MenuItemObj.ControlRef)
... I can do more experiments such as trimming down Andrew's demo code and then bolting on my sequences.
senderText = MenuItem2.Text
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?