Enigma20xx Posted March 27, 2024 Posted March 27, 2024 I know it is possible from a button. But is there any workaround to do it from a portal row (button)? Thank you.
comment Posted March 27, 2024 Posted March 27, 2024 I am struggling to understand your question. Please provide more details.
Enigma20xx Posted March 27, 2024 Author Posted March 27, 2024 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?
comment Posted March 27, 2024 Posted March 27, 2024 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?
Enigma20xx Posted March 27, 2024 Author Posted March 27, 2024 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"...
Søren Dyhr Posted March 27, 2024 Posted March 27, 2024 58 minutes ago, Enigma20xx said: No, the target field is in the main table. Perhaps something in the vicinity of this? us-500 Converted.fmp12
comment Posted March 27, 2024 Posted March 27, 2024 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.
Enigma20xx Posted March 27, 2024 Author Posted March 27, 2024 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
comment Posted March 28, 2024 Posted March 28, 2024 You are right, it's not as simple when using Insert Calculated Result. I did this a very long time ago, and I forgot how difficult it was. It's only slightly easier now with script triggers and global variables. See if the attached demo makes sense. InsertFromLibrary.fmp12
Enigma20xx Posted March 28, 2024 Author Posted March 28, 2024 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.
Søren Dyhr Posted March 28, 2024 Posted March 28, 2024 (edited) 10 hours ago, comment said: I don't see how this relates. No it was for the other thread: --sd Edited March 28, 2024 by Søren Dyhr
comment Posted March 28, 2024 Posted March 28, 2024 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).
Enigma20xx Posted March 28, 2024 Author Posted March 28, 2024 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
comment Posted March 28, 2024 Posted March 28, 2024 (edited) 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 March 28, 2024 by comment
Enigma20xx Posted March 28, 2024 Author Posted March 28, 2024 You are the elegant man my friend, I'm just a rookie. 🤣👍
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now