iOS Question InputDialog function?

techknight

Well-Known Member
Licensed User
Longtime User
Is there an InputDialog function for B4I? I forget what library it was in for B4A.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   NavControl.ShowPage(Page1)
End Sub

Sub Page1_Click
   Dim no As NativeObject = Me
   no.RunMethod("ShowInputDialog::", Array("This is the title", "Message"))
End Sub

Sub InputDialog_Result(Text As String)
   Log("Result: " & Text)
End Sub

#If OBJC
- (void)ShowInputDialog:(NSString*)Title :(NSString*)Message
{
  UIAlertView * alert = [[UIAlertView alloc] initWithTitle:Title
     message:Message delegate:self cancelButtonTitle:@"Hide" otherButtonTitles:nil];
   alert.alertViewStyle = UIAlertViewStylePlainTextInput;
  alert.delegate = self;
  [alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   [self.bi raiseEvent:nil event:@"inputdialog_result:" params:@[[[alertView textFieldAtIndex:0] text]]];
}
#End If
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Perfect. But....

I have a few different subroutines that grab input and have different prompts, Now how to handle those in the InputDialog event? It seems there's only 1 event, so need some kind of sender or primary key to let the event know "which" subroutine I am dealing with.

I guess i could have multiple Voids, one for each subroutine.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
nevermind. I just threw an integer variable in the globals and used that to track what its doing.
 
Upvote 0
Top