iOS Question Creating a simple Right Menu

Markos

Active Member
Licensed User
Longtime User
Hi Erel,

I would like to create a simple Top Right menu with 3 buttons and each button has an event to run code. I am posting the code to know what is correct and if any part is redundant. Also any reason we use the new NavigationController rather than the one passed as a parameter for Application_Start?

Code

Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private smc As SideMenuController
End Sub

Private Sub Application_Start (Nav As NavigationController)
'create a new navigation controller
Dim nc As NavigationController
nc.Initialize("nc")
NavControl = nc
Dim btn1 As Button
btn1.Initialize("btn1")
btn1.Text = "Halt"
Dim btn2 As Button
btn2.Initialize("btn2")
btn2.Text = "Configure"
Dim btn3 As Button
btn3.Initialize("btn3")
btn3.Text = "Drones"
Dim rp As Page
rp.Initialize("rp")
rp.RootPanel.Color = Colors.Green
rp.RootPanel.AddView(btn1,20,20,100,30)
rp.RootPanel.AddView(btn2,20,60,100,30)
rp.RootPanel.AddView(btn3,20,100,100,30)
smc.Initialize(Null, nc, rp)
App.KeyController = smc
Page1.TopRightButtons = Array(smc.CreateBarButton("Menu"))
nc.ShowPage(Page1)
End Sub


Sub Page1_BarButtonClick (Tag As String)
Select Tag
Case "Menu"
smc.OpenRightMenu
End Select
End Sub

Sub Page1_Click
smc.OpenRightMenu
End Sub

sub btn3_click
DroneE
end sub

sub btn2_click
ConfigureE
end sub

sub btn1_click
timer1.Enabled=False
timer2.Enabled=False
timer3.Enabled=False
timer4.Enabled=False
timer5.Enabled=False
timerdelay.Enabled=False
timersocket.Enabled=False
end sub
 

Markos

Active Member
Licensed User
Longtime User
Please note DroneE and ConfigureE are sub's with code. Also Page1 is populated with Panels and images etc. My APP ponly has Page1 and I manage what is seen using Panel1.visible, Panel2.visible etc. I'm porting my B4A App which uses that approach.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

There is no standard overflow menu in iOS. However you can use ActionSheet to implement a similar solution.

See the attached example.

It is hard to understand your current code. If you like you can upload the complete project (File - Export as zip).
 

Attachments

  • MenuWithActionSheet.zip
    2.1 KB · Views: 226
Upvote 0

Markos

Active Member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

There is no standard overflow menu in iOS. However you can use ActionSheet to implement a similar solution.

See the attached example.

It is hard to understand your current code. If you like you can upload the complete project (File - Export as zip).

Hi Erel

The Action sheet method might be a qucik best fit. I will try it 1st before going the side menu route. Do I have to load a layout for Page1 to work or can I just declare and initialise a page if I'm programmatically adding viewable objects?

Cheers

Mark
 
Upvote 0
Top