D davemorris Active Member Licensed User Longtime User Aug 2, 2019 #1 Hi Guys I am trying to convert a project which runs on both B4A and B4I to be cross platform. I have started with converting the B4A, but hit a query. How do I deal with AddMenuItem - I am trying to move as much code as possible to X-platform class as suggested by Erel in https://www.b4x.com/etp.html?vimeography_gallery=1&vimeography_video=256289568 It looks to me that the AddMenuItem must remain in the Activity code along with the related event handlers. Basically, am I missing something or is that how it is! Kind regards Dave
Hi Guys I am trying to convert a project which runs on both B4A and B4I to be cross platform. I have started with converting the B4A, but hit a query. How do I deal with AddMenuItem - I am trying to move as much code as possible to X-platform class as suggested by Erel in https://www.b4x.com/etp.html?vimeography_gallery=1&vimeography_video=256289568 It looks to me that the AddMenuItem must remain in the Activity code along with the related event handlers. Basically, am I missing something or is that how it is! Kind regards Dave
Erel B4X founder Staff member Licensed User Longtime User Aug 3, 2019 #2 1. Cross platform code is a tool, not a target by itself. 2. There is no identical feature in iOS. You can choose to use a different solution such as B4XDrawer. 3. Another option is to use ActionSheet in B4i and the standard menu in B4A. You can always catch the events in the activity and delegate them to the cross platform class. Upvote 0
1. Cross platform code is a tool, not a target by itself. 2. There is no identical feature in iOS. You can choose to use a different solution such as B4XDrawer. 3. Another option is to use ActionSheet in B4i and the standard menu in B4A. You can always catch the events in the activity and delegate them to the cross platform class.
D davemorris Active Member Licensed User Longtime User Aug 3, 2019 #3 Hi Erel Thanks for the response - Guess I should not have mentioned X-Platform - it has thrown you in the wrong direction (but fully agree with what you say). This currently only relates to B4A code (not B4i). I initialize the helper class using some like classname.initialize(Activity) Then in the helper class initialize is declared something like Code: Copy Public Sub Initialize (parent As B4XView) parent.LoadLayout("fromToDisplay") End Sub ' What I would like to is add menu options to the activity but put the code in the helper class i.e. Code: Copy Public Sub Initialize (parent As B4XView) parent.LoadLayout("fromToDisplay") ' Tried this by it don't work parent.AddMenuItem("Option description", "HandlerName") ' Plus some menu options End Sub IMPORTANT: I have to say that I am a BIG supporter of your attempts to support X-Platform - In my opinion, if you are writing any application for multiple platforms - it is a must to use B4X. Very kind regards Dave Last edited: Aug 3, 2019 Upvote 0
Hi Erel Thanks for the response - Guess I should not have mentioned X-Platform - it has thrown you in the wrong direction (but fully agree with what you say). This currently only relates to B4A code (not B4i). I initialize the helper class using some like classname.initialize(Activity) Then in the helper class initialize is declared something like Code: Copy Public Sub Initialize (parent As B4XView) parent.LoadLayout("fromToDisplay") End Sub ' What I would like to is add menu options to the activity but put the code in the helper class i.e. Code: Copy Public Sub Initialize (parent As B4XView) parent.LoadLayout("fromToDisplay") ' Tried this by it don't work parent.AddMenuItem("Option description", "HandlerName") ' Plus some menu options End Sub IMPORTANT: I have to say that I am a BIG supporter of your attempts to support X-Platform - In my opinion, if you are writing any application for multiple platforms - it is a must to use B4X. Very kind regards Dave
Erel B4X founder Staff member Licensed User Longtime User Aug 4, 2019 #4 You can add menu items in the class however the menu events will be raised in the activity module. You can set the event name of all menu items to be the same (Menu for example) and then delegate the click event to the class: Code: Copy Sub Menu_Click MyClass.MenuClicked(Sender) End Sub 'in the class Public MenuClicked(Text As String) Log(Text) End Sub Upvote 0
You can add menu items in the class however the menu events will be raised in the activity module. You can set the event name of all menu items to be the same (Menu for example) and then delegate the click event to the class: Code: Copy Sub Menu_Click MyClass.MenuClicked(Sender) End Sub 'in the class Public MenuClicked(Text As String) Log(Text) End Sub
D davemorris Active Member Licensed User Longtime User Aug 4, 2019 #5 Hi, Erel Thanks for the quick response - I will give it a try. Kind regards Dave Upvote 0
D davemorris Active Member Licensed User Longtime User Aug 5, 2019 #6 Hi, Erel I still can't see how to add menu items from within a class (see previous posts for my failed attempt). Kind regards Dave Upvote 0
Hi, Erel I still can't see how to add menu items from within a class (see previous posts for my failed attempt). Kind regards Dave
Erel B4X founder Staff member Licensed User Longtime User Aug 6, 2019 #7 Change the type of 'Parent' to Activity. Upvote 0
K kstainsb Member Licensed User Longtime User Aug 6, 2019 #8 One option could be to replace the Android menuitem (which is a bit restrictive) and iOS top bar icons with a popup menu (see https://www.b4x.com/android/forum/threads/b4x-mypopup-popup-menu-b4a-b4i.106882/ ). You can anchor this to any view e.g. a button at the top right. It works quite well in practice. Upvote 0
One option could be to replace the Android menuitem (which is a bit restrictive) and iOS top bar icons with a popup menu (see https://www.b4x.com/android/forum/threads/b4x-mypopup-popup-menu-b4a-b4i.106882/ ). You can anchor this to any view e.g. a button at the top right. It works quite well in practice.