LiveCode for FM Manual Getting StartedHow do I use a built in custom component?

How do I use a built in custom component?

LiveCode for FM includes a PDF Selection dialog which is a custom component created in LiveCode using the XPDF external. It is very easy to use in your solutions to take text or image selections of a PDF. In this lesson we will alter the `Research Notes` example solution to append quotes to the `Note` field.

Creating the solution

The `Research Notes` solution is an example starter solution provided with FileMaker. To create a solution based on it choose `File > Get Started...` from the FileMaker menubar.

Scroll down and click `See advanced solutions >`

In the Starter Solution dialog click `Research Notes` then `Choose` then choose a location to save the file.

The solution will open to a layout with a tab button for Notes, Documents and Media. Click on Documents then on the `Edit Layout` button.

Add an add quote from selection button

Choose the button tool from the status toolbar

Draw a button next to the clear notes bin icon

Right click the new button and choose `Button Setup`

Setting the button icon

Select an appropriate icon and choose `Perform Script` from `Action` option button.

Add a script to the button

Click the + icon on the `Specify Script` dialog to create a new script. Name the script and click `OK`.

Add the script

Add a `Set Variable` script step(1) and press Enter.

Click the cog icon(2) to open the script step options dialog.

  1. Enter `$selection` in the `Name` field.
  2. Click the `Specify...` button to specify a calculation to set the variable to.

Set the script of the calculation to the following script and click `OK`

LC ( "LCPDFSelection"; Documents::File | Container; "text")

and click 'OK'.

Click `OK` in the `Set Variable` options dialog to return to the `Select Quote` script.

At this point the button will set the value of the '$selection' variable to the text selected from the PDF, or empty if none was selected.

Before appending the selection to the Notes field we will check to ensure it isn't empty.

LC ( "LCPDFSelection"; Documents::File | Container; "text")

  1. Add an 'If' step.
  2. Click on the 'fx' button to open the 'Specify Calculation' window.
  3. Set the calculcation to $selection  ≠ "" . This checks that the $slection variable is not empty.
  4. Click OK to close the 'Specify Calculation' window.

Now we have checked the selected is not empty we specify what to do with the selected text. In this case we want to append the selected text to the 'Note' field.

  1. Add a 'Set Field' step within the 'If' statement.
  2. Click on the cog to open the field options section.
  3. Click the 'Specify' button to specify the target field. Select Documents in the dropdown menu at the top of the dialog window, then select the 'Note' field.
  4. Click the 'Specify' button to specify the calculation for the result and set the calculation to
If ( Documents::Note = "" ; 
   Quote ( $selection );
   Documents::Note & "¶" & Quote ( $selection )
)

This checks if the 'Note' field is empty, if so the 'Note' field is updated with the selected text, held in the $selection variable.

Click 'OK' to close the Script editor and close the Button Setup window.

Testing

Click the `Exit Layout` button and then the `Documents` tab. Drag a PDF to the container field and click the button you created.

Select some text and click the done button on the PDF Selection dialog.

The selected quote will be appended to the note field.

0 Comments

Add your comment

E-Mail me when someone replies to this comment