Jump to content

OnObjectEnter script trigger


This topic is 2938 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi,

I have a text field formatted as an Edit Box. I've attached a simple script to run OnObjectEnter. The script, which I can't attach here since I'm on my iPad, checks to see if the active field is formatted as bold or not, and toggles the bold state on/off, and works a treat. I click on it and if it's not bold it becomes bold and vice-versa. The purpose of this is to indicate to the reader that this instance, in bold, is the first a given musician has played in a given production. However, when I change the field to a pop-up menu, the script won't fire. It's as if the field never becomes active. Anyone else encountered this issue?

Rick.

Link to comment
Share on other sites

As far as the OnObjectEnter trigger is concerned, a field formatted as a pop-up menu is "entered" after the user makes a selection. (Interestingly, the script parameter for the trigger evaluates before the menu renders, but I don't think that helps you much.)

Link to comment
Share on other sites

Yes. Setting the field to select all when selected does set the bold as on, but this is not efficient since the bold formatting is the exception rather than the norm. In other words the field formats as bold when a value is selected. It seems to me that when a field is selected, regardless of whether it's a drop down, pop-up or whatever, it should be the active field and subject to the GetActiveField functions.

Link to comment
Share on other sites

Unrelated to your question, but text formatting is not a good vehicle for storing data.

This is simply a display issue. At the beginning of a given week of performances I send the conductor a list (PDF) of substitute musicians. The bold formatting indicates a first time occurrence of this particular musician's participation. It's hardly necessary, but it is a nice touch. I will work out a way of achieving the necessary formatting on a data level rather than by clicking on the field. Less clicks, less tedium.

Edit: I just realized the mechanism for this is already in place on another layout. All I have to do is adapt it to the relevant context. I guess we're always leaving bread crumbs . . .

Rick.

Link to comment
Share on other sites

 It seems to me that when a field is selected, regardless of whether it's a drop down, pop-up or whatever, it should be the active field

 

That's true - but the way it's implemented, the field does not become selected/active until after the pop-up menu collapses. The pop-up menu is sort of like a button in front of the field.

 

 

This is simply a display issue.

 

It will become a display issue once you have a field to hold the fact. Then you can use conditional formatting to display the fact as bold, italic etc.

  • Like 1
Link to comment
Share on other sites

Comment, thanks. However, the PopUp menu, even when collapsed, does not trigger the script. As I've said, this whole routine works fine when the field is defined as an edit box but not otherwise. I can get to it another way without creating another field and will report my results to any that are interested. Have to get back to the office first . . .

Link to comment
Share on other sites

Tabbing to a popup menu will fire OnObjectEnter trigger but popping it will not.  Try a drop-down list instead which WILL fire when popped.  BTW, same behaviour affects checkbox and radio button.  

 

Note:  I have not tested this behaviour on Windows with version 13 but I doubt it has changed.

  • Like 1
Link to comment
Share on other sites

It would help to see the exact script.  Can you save it as pdf and attach (or preview and copy it)?

 

The purpose of this is to indicate to the reader that this instance, in bold, is the first a given musician has played in a given production. 

 

I do not understand why anything needs to be activated.  As Michael has pointed out, conditional formatting should be all that is required.  You can look to the relationship to know the answer ... Do you have something like:

 

Productions -< Production_Dates >- Musicians  ?

 

Depending upon your perspective (whether from Production record looking to portal of Production_Dates (for example), conditional formatting on the field can count the related  production dates and bold if the count is less than 2.  This is an example only since we have no idea how you are related or your perspective.

 

It would remove that burden from users and solve your issue completely, Rick.  If you wish to provide more information (your relationships), we could help you further with it.


Also tabbing to popup certainly works for me on OSX 10.9.5 which is why I suspect something in the script might be causing it not to work.  Are you running debugger when you try it?

Link to comment
Share on other sites

If you do not have an already-made relational structure, you can also use ExecuteSQL() in the conditional formatting calc to count how many times a musician is on a Production.  

Link to comment
Share on other sites

It would help to see the exact script.  Can you save it as pdf and attach (or preview and copy it)?

 

On the Mac, you can print to PDF and Preview and then copy the script in the Preview and past it here. 

Link to comment
Share on other sites

Thanks LaRetta,

I believe I have a way to do this on a data level without user action. Too bad I think of answers when away from my computer! Even though I won't likely continue using it, I will post the small script when back in frontbof a real computer. As far as the relational structure goes, it's way more complicated than what you mention. Substitute musicians get a share of pension for one thing. For another, the instances of using substitutes are counted for each principle musician to conform to various possible Collective Agreements . . . It goes on. So the PK for these records is related in many ways to many entities. There is a relational path however and I will go the Conditional Formatting route.

Thanks Comment as well.

Link to comment
Share on other sites

Here's the little script. Add_Remove_Bold. Works well on a field defined as an edit box.

 

Triggered: Add_Remove Bold 

 

If [ PatternCount ( GetAsCSS ( Get ( ActiveFieldContents ) ); "bold") = 0 ] Set Field [ TextStyleAdd ( Get ( ActiveFieldContents ); Bold )

Else
Set Field
[
TextStyleRemove ( Get ( ActiveFieldContents );Bold )

End If 

Link to comment
Share on other sites

Interesting that on the same layout I have other fields formatted as pop-ups using a value list whose values come from a related file/table. These fields fire an OnObjectSave script (different script) and it works every time. The purpose of this whole exercise is to eliminate certain table occurrences and layout objects to achieve increased efficiency in a db I began building ages ago. Obviously I'm still building it.

Link to comment
Share on other sites

Good to know you're making headway!  :-)

 

Well, originally the trigger was OnObjectEnter not OnObjectSave.  I do not believe we ever discussed OnObjectSave.   It is only OnObjectEnter where popups, radio buttons and checkboxes will not activate upon selecting them.

Link to comment
Share on other sites

I've also tried OnObjectSave on the original field I mentioned. At least I hope I have! I'll check again when I get back. At one point I thought the issue was the value list, but seeing that it works fine in the most recently mentioned instance leads me to think that this isn't the problem. Thanks.

Link to comment
Share on other sites

This topic is 2938 days old. Please don't post here. Open a new topic instead.

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
 Share

×
×
  • Create New...

Important Information

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