Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Get ( ActiveSelectionStart ) Behavior Issue

Featured Replies

I have a script that attempts to set a global variable to the value of the fields current cursor position via an OnObjectEneter and OnObjectKeyStroke script trigger. The global variable is set with the Get ( ActiveSelectionStart ) function in a one line script using Set Variable script step. I am getting problems arising that I do not understand the root of.

When entering the empty field the variable returns 1, which is ok, then after entering one character the variable still returns 1. Furthermore if I move the cursor back a position the variable returns 2 when the cursor is position 1.

A script triggered OnObjectKeyStroke runs before the triggering event itself is performed.

Please post your file or a simplified example file containing your script and showing how you are triggering it.

  • Author

Here is a sample file. Select and type something in the field and watch the $$CursorPosition in the data viewer change as describe. Script is triggered by OnObjectEnter ( to capture initial position) and OnObjectKeystroke (to capture change in position). I think I may need to use the Get(TriggerModifierKeys) with case logic to get the functionality I want. I'll post whatever I come up with if someone doesn't suggest something better first.

Example.fp7.zip

What is your purpose here? The current cursor position is available at all times directly from Get (ActiveSelectionStart) - why is it necessary to store it in a variable?

  • Author

I wanted to make a pop-up menu work that inserted a selected operator into the stored location and since it is not possible to make a pop-up menu appear when it is scripted to via Goto Field script step I tried this crazy work around - also realized that changing cursor position with mouse while field is active gave an empty value so that killed this idea too.

I settled for a value list, used a button and everything works snappy and looks nice - also no script triggers are needed on fields from which cursor position is desired.

My purpose was to mimic the insert find operator that is available in find mode for a custom navigation bar. I am still curious -but not urgently - about the behavior of the Get ( ActiveSelectionStart ) while the global variable is capturing data via OnObjectKeystroke script trigger.

Would something like this work for you?

InsertValue.zip

Aloha in the Hawaiian language means affection, love, peace, compassion and mercy. :

LOL - in this case it means my finfer slipped...

  • Author

Thanks for posting insertvalue.fp7 that really helped getting a handle on inserting data - I was using a replace function with the GetFeildByName script step :bang: . I've attached a file of what I've done. I bundled $$Start, $$end, and active field data into one variable array and used Goto Object to limit this to one script for multiple fields. Also used a button to capture field and cursor position to limit the need to attach a scrip trigger to all fields on the layout and stuck with a value list on the field. Still needs some tightening up but wanted to get something posted. Thanks.

On a final note Is it possible to get a fields pop up to activate via script?

ExampleOperator.fp7.zip

TIs it possible to get a fields pop up to activate via script?

I don't think so.

I haven't looked at your file too closely, but one thing stands out: you are using Evaluate() for no reason that I can see; for example:

Evaluate ( Get ( ActiveSelectionStart ) + Get ( ActiveSelectionSize ) -1 )

will return the same result as:

Get ( ActiveSelectionStart ) + Get ( ActiveSelectionSize ) -1

albeit with more processing. The purpose of the Evaluate() function is to convert a text string into a formula that can be evaluated - this is required only rarely.

  • Author

Ok, I swear this was working last night. Maybe I should have went to sleep earlier. And I'm not sure what I was thinking with the evaluate their. Also for some reason I thought the Goto Object script step would take me to a field by its table name that I didn't have named as an object - working after you've been working leads to interpreting things wrong.

All right who really inserts find operators anyway. If you use them frequently you memorize them. One last hope here maybe I'm missing this so heres the question.

Is there a way to Goto Field by Name like Set Field by Name?

Edited by Guest

Is there a way to Goto Field by Name like Set Field by Name?

No. You must assign object names to your fields and use Go to Object[].

  • Author

Yes. There is a way - see attached file - taking a step out of the box I remembered something I wanted to try. This uses a global field to send data to, drum roll please... Applescript! From which I can use go to field with a variable I set in Applescript with the value of the global field which in turn is the value of $$FieldSelection - array position 1.

:woohoo:

ExampleOperator.fp7.zip

As workarounds go, the Go to Object[] route is cross-platform compatible.

  • Author

What about VB script?

Also I want to insert find operators into any field in find mode and I don't want to have to be creating an object for every field I have on a layout just like I don't want script triggers on every field.

The question is why isn't there a Goto Field by Name, seems like a no brainer. Is the underlying code tied in crazy nots or something.

why isn't there a Goto Field by Name

That's a good question. Many people have been asking the same about Set Field By Name[] until it has been added in version 10 - so it could be merely a question of time.

I want to insert find operators into any field in find mode

I wonder why you bother with that. The experienced user can use the built-in mechanism; for others, I'd prefer a custom UI and a script-generated request - see for example:

http://fmforums.com/forum/showtopic.php?tid/192929/post/279953/#279953

  • Author

Thanks, but I'd rather have people learn how to use the find mode with new requests, I think it can get confusing for end users especially in my field when there are suddenly different layouts fields in find mode. Also I wan't to hide the toolbar to have a consistent GUI which is critical for me, plus my toolbar is a third the size, maintains advanced user tools and can contain the layout title as well as other useful things I can't put in the standard tool bar. Anyways I'm almost done roughing this out just need to add saved finds and utilize one set of global fields from a resource table at which point the only thing to do when building a new layout is copy and paste the toolbar.

  • Author

Looks like in the end I can ditch the global and build a custom function that inserts what I want into the AppleScript before it runs.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.