« Virtual Xojo User Gro… | Home | XojoTalk podcast 2^5 »

Image Picker for FileMaker iOS SDK apps with MBS Plugin


Another function set for iOS is done: ImagePicker. It allows you to pick photos from the saved camera roll, the photo library and take a new picture via camera. You can control a lot of settings, e.g. whether to allow editing or which camera (front or rear) to use.

In all cases we call a script trigger later when the user selected an image. There you can take the picture and add it to a container field in your database.

Here is the same script to show the picker. Source Type is for example "Camera":

Set Variable [ $SourceType ; Value: Get(ScriptParameter) ] 

Set Variable [ $r ; Value: MBS( "ImagePicker.IsSourceTypeAvailable"; $sourceType ) ] 

If [ $r ≠ 1 ] 

Show Custom Dialog [ "Can't pick picture." ; "The source " & $sourceType & " is not available." ] 

Exit Script [ Text Result: "failed" ] 

End If

Set Variable [ $r ; Value: MBS( "ImagePicker.New" ) ] 

Set Variable [ $r ; Value: MBS( "ImagePicker.SetScript"; Get(FileName); "GotImage") ] 

Set Variable [ $r ; Value: MBS( "ImagePicker.SetSourceType"; $sourceType) ] 

Set Variable [ $r ; Value: MBS( "ImagePicker.SetAllowsEditing"; 1 ) ] 

Set Variable [ $r ; Value: MBS( "ImagePicker.SetCameraCaptureMode"; "Photo" ) ] 

Set Variable [ $r ; Value: MBS( "ImagePicker.SetCameraDevice"; "Front" ) ] 

Set Variable [ $r ; Value: MBS( "ImagePicker.SetCameraFlashMode"; "Auto" ) ] 

Set Variable [ $r ; Value: MBS( "ImagePicker.SetShowsCameraControls"; 1 ) ] 

Set Variable [ $r ; Value: MBS( "ImagePicker.Present") ] 

 

Later this script is called:
 

Set Variable [ $r ; Value: MBS( "ImagePicker.Dismiss" ) ] 

If [ Get(ScriptParameter) ≠ "Cancel" ] 

If [ MBS( "ImagePicker.HasMedia" ) ] 

New Record/Request

Set Variable [ $Image ; Value: MBS( "ImagePicker.MediaEditedImage"; "PNG") ] 

If [ IsEmpty ( $image ) ] 

Set Variable [ $Image ; Value: MBS( "ImagePicker.MediaOriginalImage"; "PNG") ] 

End If

Set Field [ ImagePicker::Picture ; $image ] 

Commit Records/Requests [ With dialog: Off ] 

End If

End If

 
As you see we dismiss the dialog and add the picture to a container. But of course more is possible, e.g. by taking a picture automatically.
We'll see what wonderful solutions you will build using our plugin!  See you at DevCon in Phoenix.
20 06 17 - 18:20
No comments

  
Remember personal info?

Emoticons / Textile


Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.