Drag and Drop Example for FileMaker Pro 7

To begin, please download and open the example database.

Download the example file (FileMaker 7 required)


Drag and Drop Test..

To test out this solution, try typing something into the "some text" field. The "some text container" field will update to the text you typed in. This field is simply a calculation field referencing the "some text" field with a result of container.

Next, click and drag the text from the "some text container" field into the "active text" field. At this point, the "active text unmodified" field will update to the text that you dragged into the "active text" field.

Lastly, try typing something into the "active text" field. Though you can change the contents of "active text", the "active text unmodified" field will not change - unless you drag and drop as mentioned above.

How it all works...

This example consists of 4 fields:

1. some text - text field
This field is simply a text field. There is nothing special about it.
2. some text container - calculation field which references "some text" as a container
This field is a calculated container field. Because of this, we get a few special qualities that are useful. First, its not editable. Second, because it is a container field, it is dragable (is that a word?).
3. active text - text field with an auto enter calculation.

The "active text" field is only special in that it has an auto entered calculation as follows:

Let (

   [
      selftrigger = active text
   ];

   Get ( ActiveFieldContents )

 )

Using the "Let" function is helpful because we can use a variable to reference the "active text" field, which is the field we are auto entering to begin with. This forces the field to update anytime it thinks it is modified.

The trick is, when you try to drag the contents of a container field to to a text field, you do not get anything in the text field, because the two field types are incompatible. However, the text field in this case thinks that it has been modified, and the container field is actually still the active field. So we can simply use the new "Get ( ActiveFieldContents )" function to retrieve the text string from the container field.

This is all fine and dandy, but the user can still edit the contents of the "active text" field. If this field is to be a relationship key or simply needs to stay clean then we can go a step farther and create the "active text unmodified" field. In other words, a field that stays clean.

4. active text unmodified - text field with an auto enter calculation.

This field does not have to be on the layout in order to work. The nice thing here is a user can see that there is something in the "active text" field and even edit it, but we can use the "active text unmodified" field for relationships or what have you.

This field is an auto entered calculation as follows:

Let (

   [
      selftrigger = active text
   ];

   Case ( Get ( ActiveFieldName ) <> "active text" ; active text ; active text unmodified)

 )

Unfortunately, you MUST have the "active text" field name in quotes above. This can confuse a lot of people, but it is necessary because we are testing for a string which happens to be a field name. If you decide at some point to change the name of your field, you will need to come back and change this string to match.

The trick to this field is similar to the auto enter field "active text" with one simple modification. This field is only changed if the active field is NOT "active text". The trigger is still the "active text" field, so that anytime the "active text" field is modified this field ("active text unmodified") is updated. If the update is triggered, and the active field turns out to be "active text" then we simply copy the value already in the "active text unmodified" field.

Conclusion and Final notes...

I know that is a mouthful, but I wanted to try to be as clear as possible on what each field does. I hope the end result is not to overwhelming with all of the field names everywhere.

One last note, in my testing I found that you cannot update the "active text" field with other text fields via drag and drop. However, if you have other container fields, you can update the field. I suppose it is up to the solution you are working on if this is good or bad news.

Enjoy -

Jesse Traynham.

Download the example file (FileMaker 7 required)

...more entries
<- September 2010 ->
S M T W T F S

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30


Jesse.Traynham.com
π