Jump to content
Server Maintenance This Week. ×

Insert text at cursor.


Recommended Posts

Inserting text in a field at cursor position. Setting a button with a single script step (insert text/calculated result), it works because the active object doesn't change by pressing a button.

What I'm trying to accomplish is the same, but from a button in a portal row. This makes you exit the field, and it doesn't work.

My question is, is there any workaround to do it from the button in the portal row?

Link to comment
Share on other sites

24 minutes ago, Enigma20xx said:

a button in a portal row. This makes you exit the field

Is the target field in the same portal row as the clicked button?

Or perhaps I should ask first: is the target field in the portal at all?

 

Link to comment
Share on other sites

9 minutes ago, comment said:

Or perhaps I should ask first: is the target field in the portal at all?

No, the target field is in the main table.

I try to accomplish some kind of letters merging (I don't know if it's the correct definition).

Parent table has the letter and the child table has the "variables"...

Link to comment
Share on other sites

58 minutes ago, Enigma20xx said:

No, the target field is in the main table.

That's problematic. Unless the target field is constant and can be included in the Insert Text step, you will need to find a way to store the target field's name somewhere before clicking the button in portal.

 

6 minutes ago, Søren Dyhr said:

Perhaps something in the vicinity of this?

I don't see how this relates.

Link to comment
Share on other sites

50 minutes ago, comment said:

Unless the target field is constant and can be included in the Insert Text step, you will need to find a way to store the target field's name somewhere before clicking the button in portal.

The target field name is constant, nevertheless I grab it in a global variable and then use it in the set field by name scrip step (I don't know how to do it now with insert calculated result scrip step).

This works but only inserts the text at the end of the text. Not where the cursor was. I still can't make this part work.

Prueba.fmp12

Link to comment
Share on other sites

I was just testing grabbing the whole text into a global variable, splitting it into two, one before the cursor (Get ( ActiveSelectionSize )) and another after it, and then merge the first part, my chunk and the second part.

But your sample is just awesome.

Thank you very very much.

Link to comment
Share on other sites

10 hours ago, comment said:

I don't see how this relates.

No it was for the other thread:

--sd

 

 

Edited by Søren Dyhr
Link to comment
Share on other sites

7 hours ago, Enigma20xx said:

your sample is just awesome

There is one aspect I am still not happy with:

Ideally, clicking one of the buttons while the target field is not active should not do anything. Instead, it activates the field and inserts the text at the last cursor's position. 

Alas, I wasn't able to find a solution for that (at least not a reasonable one).

 

Link to comment
Share on other sites

I think I have been able to solve the issue (any idea if doing it with a complicate workaronund, but I think it works).

1. Adding a global variable to the scrip trigger “Get selection” to grab the active field name.

2. Adding an If step to the “Insert snippet” script, to bypass everything if the $$fieldActive variable doesn’t match the name of the field where to insert the text.

3. Adding a new script to empty all global variables, attached as a script trigger to the other field OnObjectEnter and to the Layout OnRecordCommit.

In my opinion this works.

InsertFromLibrary - copy.fmp12

Link to comment
Share on other sites

Adding another script triggered by entering any other field layout object or by committing the record would do it. But I was hoping for something more elegant...

 

Edited by comment
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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