Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.databases.filemaker > #3228
| From | Helpful Harry <HelpfulHarry@BusyWorking.com> |
|---|---|
| Newsgroups | comp.databases.filemaker |
| Subject | Re: Scripting: Putting the Cursor into a Specific Field |
| Date | 2018-10-28 18:15 +1300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <pr3glc$1ecr$1@gioia.aioe.org> (permalink) |
| References | <1nx0y5j.3xtd161uvtfy1N%csampson@inetworld.net> <pqj67c$1bf2$1@gioia.aioe.org> <1nx2zwi.11xzs38gew5uwN%csampson@inetworld.net> <pqmecr$d8a$1@gioia.aioe.org> <1nxakf2.12dghzr6wj5kvN%csampson@inetworld.net> |
On 2018-10-27 02:02:11 +0000, Charles H. Sampson said: > Helpful Harry <HelpfulHarry@BusyWorking.com> wrote: > >> On 2018-10-23 00:23:14 +0000, Charles H. Sampson said: >>> Helpful Harry <HelpfulHarry@BusyWorking.com> wrote: >>>> On 2018-10-21 21:20:36 +0000, Charles H. Sampson said: >>>>> >>>>> In a script, how do I remember a field and later put the cursor into >>>>> that field and make it the active field? I've experimented with Go To >>>>> Object and Set Field by Name (in this case setting it to its saved >>>>> initial contents). In spite of what the online documentation seems to >>>>> say, neither of these leaves the cursor in the field/object, instead >>>>> putting it into the next field in tab order. >>>>> >>>>> Am I misreading? Am I doing something else wrong? >>>>> >>>>> FMP 16. >>>> >>>> Each new re-worked version of FileMaker Pro just gets messier and >>>> messier. Even the Script "Workspace" (the stupid name for the Script >>>> Editor) is unnecessarily over-complicated. :o( >>>> >>>> This function used to be very easy, but now it seems to be somewhat >>>> more complicated. I managed to get it to work using this technique ... >>>> >>>> 1. In Layout Mode, click in each Field on the Layout one at a time >>>> and give each a unique Object Name in the silly Inspector palette >>>> (for the sake of ease of use and understanding, it's probably best >>>> to simply use an Object Name which is the as the Field's name in >>>> the Define Fields window). >>>> >>>> 2. Create a new Global Text Field called g_ActiveField which the Scripts >>>> can use to store the currently active Field's Object Name (you can >>>> probably use a Variable if you prefer). >>>> >>>> 3. Now you can use two commands in your Scripts: >>>> - to store the Object Name of the currently active field use >>>> Set Field [g_ActiveField; Get(ActiveLayoutObjectName)] >>>> >>>> - to go to the Field stored in g_ActiveField >>>> Go To Object [Object Name: g_ActiveField] >>> >>> I've tried this, using both the global field and the variable, and I >>> can't get it to work. Here's what I've discovered: My script is >>> triggered by exit the field (the field object). I hoped that this would >>> activate as I tried to exit the field but before the field is actually >>> left. That seems to be the case. I begin by capturing three pieces of >>> data: the field's name, using both techniques, and the contents of the >>> field. Much later I use a custom dialog to display these data and they >>> are what they should be. >>> >>> I exit the field in question by clicking in another field, including >>> another field of a different record. After the script executes the Go To >>> Object or Set Field by Name step, that field is where the cursor is >>> placed. >>> >>> I've tried all four combinations of Set Variable/Set Field and Go To >>> Object/Set Field by Name. >>> >>> And here's the latest word: I've just discovered that Set Field By Name >>> isn't working at all. Instead of setting the field to its previously >>> saved initial value, I tried to set it to a different value. The initial >>> value is what showed up. >> >> When you run the 'Go To' Script it causes the database to exit the >> second field (even though it doesn't deactivate) causing the 'Exit' >> Script to be run first, which of course changes the data for the Field >> it will return to. >> >> It's a clumsy approach, but what you can do is capture the Previous >> Field's Object Name separately: >> >> - Create another Global Text Field (or variable) called >> g_PreviousActiveField >> (You will also need another Field to similarly capture >> the field data) >> >> - Create a new Script with the command: >> Set Field [g_PreviousActiveField; g_ActiveField] >> >> - In Layout Mode, set all the necessary Fields to also >> have an OnObjectEnter trigger using the above Script >> >> - Change the 'Go To' Script to use the g_PreviousActiveField >> Field: >> Go To Object [Object Name: g_PreviousActiveField] >> >> >> What now happens is: >> - Exiting a Field triggers the Exit Script, so stores that Field's >> Object Name in the g_ActiveField. >> >> - If you have clicked in another Field, it will trigger the >> Enter Script, which copies the current contents of g_ActiveField >> to g_PreviousActiveField. >> >> - When you run the 'Go To' Script, it goes to the correct field >> because it's ignoring the change to g_ActiveField occuring due to >> the 'Go To' Script first triggering the Exit Script from the >> second Field. >> >> All clear as mud?? :o) >> >> >> This works in some quick tests, but there are three problems though. >> >> 1. If you exit the first Field by clicking anywhere that isn't another >> Field (i.e. a blank space on the layout, a button, etc.), then the >> Enter Script won't be run. You might be able to workaround this by >> including a test in the 'Go To' Script, but it would depend on how >> the second problem can be solved ... >> >> 2. You'll need some way to clear the data from both g_ActiveField and >> g_PreviousActiveField. >> >> 3. If you're using a Layout in List View, then you will also need to >> capture the Record Number when exiting the Field and alter the >> 'Go To' Script to go back to the original Record as well as the >> original Field - otherwise when you click on another record to exit >> the Field, the 'Go To' will go to the correct Field, but incorrectly >> in the current Record. >> >> >> Perhaps it would help if you explain why you're trying to achieve this. >> There might be a better approach to doing what you want. > > Thanks again, Harry. It's going to take me a while to digest all this. > > What I'm trying to do: I have a script that validates input that's > supposed to be money. It catches every error I could think of and > informs the user, using a custom dialog. At present, the custom dialog > has only an OK button. After clicking on this button, the user has to > click in the field again to fix the error(s). I'd like to modify this so > the custom dialog has Fix and Accept buttons, with clicking on the Fix > button resulting in the cursor being in the erroneous field. > > One problem with my current script, which I consider better than > nothing, is that upon exiting the money field, which is just a number > field to FM, FM displays the erroneous data using its wildly lax > interpretation of the input. The result is that no particular error is > obvious, unless the user notices that the value in the field is not what > he wanted. > > The reason for wanting an Accept button is another story. > > Charlie You could highlight the field that has the error, by putting a Calculation Container field behind it on the Layout which "lights up" when there's an error in the main field's data. Should be easier and more noticeable. Helpful Harry :o)
Back to comp.databases.filemaker | Previous | Next — Previous in thread | Next in thread | Find similar
Scripting: Putting the Cursor into a Specific Field csampson@inetworld.net (Charles H. Sampson) - 2018-10-21 14:20 -0700
Re: Scripting: Putting the Cursor into a Specific Field Helpful Harry <HelpfulHarry@BusyWorking.com> - 2018-10-22 13:39 +1300
Re: Scripting: Putting the Cursor into a Specific Field csampson@inetworld.net (Charles H. Sampson) - 2018-10-22 17:23 -0700
Re: Scripting: Putting the Cursor into a Specific Field Helpful Harry <HelpfulHarry@BusyWorking.com> - 2018-10-23 19:17 +1300
Re: Scripting: Putting the Cursor into a Specific Field csampson@inetworld.net (Charles H. Sampson) - 2018-10-26 19:02 -0700
Re: Scripting: Putting the Cursor into a Specific Field none@gmail.com - 2018-10-27 16:38 +0200
Re: Scripting: Putting the Cursor into a Specific Field Helpful Harry <HelpfulHarry@BusyWorking.com> - 2018-10-28 18:13 +1300
Re: Scripting: Putting the Cursor into a Specific Field csampson@inetworld.net (Charles H. Sampson) - 2018-11-07 20:09 -0800
Re: Scripting: Putting the Cursor into a Specific Field csampson@inetworld.net (Charles H. Sampson) - 2018-11-07 19:32 -0800
Re: Scripting: Putting the Cursor into a Specific Field Helpful Harry <HelpfulHarry@BusyWorking.com> - 2018-10-28 18:15 +1300
Re: Scripting: Putting the Cursor into a Specific Field csampson@inetworld.net (Charles H. Sampson) - 2018-11-07 20:09 -0800
Re: Scripting: Putting the Cursor into a Specific Field Howard Schlossberg <howard@nospam.fmprosolutions.com> - 2018-10-21 18:15 -0700
Re: Scripting: Putting the Cursor into a Specific Field csampson@inetworld.net (Charles H. Sampson) - 2018-10-22 17:23 -0700
csiph-web