I am still stepping through the simple things but finding the docs a bit short on some examples.
I am trying to capture the toolbar presses as follows. It works fine if you have added a button and given it a caption but how do you test for example a Compose or Play type button with no caption?
Select Case button.Caption
Case “Safety Tips”
MessageBox1.Message = “Safety Tips”
MessageBox1.Show
Case “Notes”
MessageBox1.Message = “Notes”
MessageBox1.Show
End Select
Use the name of the control instead.
Select case Button.Name
Case "Button1"
// do something
Case "Button2"
//do something else
end select
You can do that for all controls, but not windows or container controls.
Hi Michael,
That gives an error as there is no .name
Select Case button.name
Case “Button5”
MessageBox1.Message = “Safety Tips”
MessageBox1.Show
Case “Button4”
MessageBox1.Message = “Notes”
MessageBox1.Show
End Select
The event is “ToolbarPressed” and it returns (button as IOSToolButton)
The only relevant case I can see is button.caption which works for bordered styled buttons but not for others
So the following only works for the first case and not the second
Select Case button.Caption
Case “Safety Tips”
'Works
MessageBox1.Message = “Safety Tips”
MessageBox1.Show
Case “Notes”
'Doesn’t work as " Notes" is a Compose Style button
End Select
Did you look at the iOS Toolbars section of the User Guide?
If you’ve added toolbar buttons using the layout editor, you can more easily check which button was pressed by using its name. For example, if you have an EditButton and a SaveButton on the Navigation toolbar, you can check to see which was pressed with this code:
Select Case button
Case EditButton
' Edit was pressed
Case SaveButton
' Save was pressed
End Select
I must be missing something Paul. I added an Edit and Save button and your code in the ToolbarPressed event handler but it doesn’t recognise button, Editbutton,save button
IOS ToolbarPressed Event Handler
Passes (button As IOSToolButton)
I have tried Paul’s suggestion above and the button.caption method in the Language Ref. Select Case Button produces an error and Button.Caption only works for Bordered Style buttons. I added a Compose Button with a caption “Notes” and can’t find a way to test if it has been pressed.
So still stuck on this code
Select Case button.Caption
Case “Safety Tips”
'Works
MessageBox1.Message = “Safety Tips”
MessageBox1.Show
Case “Notes”
'Doesn’t work as " Notes" is a Compose Style button
End Select
Look at Examples/iOS/Controls/ToolbarExample included in 2016r2.1 to see how to use the method I described.
Thanks Jean-Paul, seems a bit clunky but works
Thanks Paul that is what I was expecting to seeing 2016r2 good to see it fixed in r2.1