mcorbeel Active Member Licensed User Longtime User Apr 16, 2018 #1 I am making mt first iOS app and all is going well. However there is one thing that I do not find. I need to have a menu button at the top of a page that when clicked shows a menu. I use this code to create the top right button: Dim btn As BarButton btn.InitializeBitmap(LoadBitmap(File.DirAssets, "menu.png"), "Button_Menu") Dim btnList As List btnList.Initialize btnList.Set(0, btn) MyPage.TopRightButtons = btnList The icon is showing, but I was hoping to find the click event of that button under Button_Menu_Click but that does not work. How can I use the click event?
I am making mt first iOS app and all is going well. However there is one thing that I do not find. I need to have a menu button at the top of a page that when clicked shows a menu. I use this code to create the top right button: Dim btn As BarButton btn.InitializeBitmap(LoadBitmap(File.DirAssets, "menu.png"), "Button_Menu") Dim btnList As List btnList.Initialize btnList.Set(0, btn) MyPage.TopRightButtons = btnList The icon is showing, but I was hoping to find the click event of that button under Button_Menu_Click but that does not work. How can I use the click event?
Erel B4X founder Staff member Licensed User Longtime User Apr 17, 2018 #2 Please use [code]code here...[/code] tags when posting code. Upvote 0
mcorbeel Active Member Licensed User Longtime User Apr 17, 2018 #3 Sorry, forgot: Code: Copy Dim btn As BarButton btn.InitializeBitmap(LoadBitmap(File.DirAssets, "menu.png"), "Button_Menu") Dim btnList As List btnList.Initialize btnList.Set(0, btn) MyPage.TopRightButtons = btnList Upvote 0
Sorry, forgot: Code: Copy Dim btn As BarButton btn.InitializeBitmap(LoadBitmap(File.DirAssets, "menu.png"), "Button_Menu") Dim btnList As List btnList.Initialize btnList.Set(0, btn) MyPage.TopRightButtons = btnList
Erel B4X founder Staff member Licensed User Longtime User Apr 18, 2018 #4 1. Why aren't you adding the button with the designer? 2. You can simplify your code: Code: Copy MyPage.TopRightButtons = Array(btn) Handling the event: Code: Copy Sub Page1_BarButtonClick (Tag As String) Log("BarButton clicked: " & Tag) End Sub Upvote 0
1. Why aren't you adding the button with the designer? 2. You can simplify your code: Code: Copy MyPage.TopRightButtons = Array(btn) Handling the event: Code: Copy Sub Page1_BarButtonClick (Tag As String) Log("BarButton clicked: " & Tag) End Sub
mcorbeel Active Member Licensed User Longtime User Apr 18, 2018 #5 Thank you Erel, the event with the page name works. I prefer making my layout by code... don't know why... a (bad?) habit. Upvote 0
Thank you Erel, the event with the page name works. I prefer making my layout by code... don't know why... a (bad?) habit.
Erel B4X founder Staff member Licensed User Longtime User Apr 18, 2018 #6 mcorbeel said: a (bad?) habit Click to expand... In most cases yes. It will be much simpler to build a layout that properly adapts to the page size with the visual designer. There are two relevant videos that all B4i developers should watch: - Visual Designer - B4i / B4J - Resize event https://www.b4x.com/etp.html Upvote 0
mcorbeel said: a (bad?) habit Click to expand... In most cases yes. It will be much simpler to build a layout that properly adapts to the page size with the visual designer. There are two relevant videos that all B4i developers should watch: - Visual Designer - B4i / B4J - Resize event https://www.b4x.com/etp.html