I’m trying to figure out how to add an element to a UI dialog to display data that has been gathered by an script, either AppleScript or shell script. I’ll try to explain:
A line of text in the dialog reads "Grace logins remaining: ", and I obviously want to display the user’s remaining grace logins as a simple text character (like “6”) off to the right of this line of text.
I can write a simple applescript or shell script to actively gather the necessary data, but I don’t know exactly what to add to the dialog to display that data. I suppose it would be a sort of field, linked to the result of the script, right?
Any help would be appreciated.
Are you using a window that you have created (in IB) or are you using a standard display dialog command to bring up the dialog?
If you are using a window that you created, you could do something like:
set GracePeriod to "Grace Logins remaining: " & [however you gather the data] as text
set the contents of text field [the name of your text field here] to GracePeriod
If you are using a standard dialog you could do something like:
set GracePeriod to "Grace Logins remaining: " & [however you gather the data] as text
display dialog GracePeriod buttons {"OK"} default button "OK"
I am just typing this up off the top of my head, but this should hopefully get you going.
Brad Bumgarner, CTA
I’ve got the AppleScript part working fine, formatting the text to be displayed in the field. However, I’m missing whatever it is I need to make the text show up in the field. All I get in the field is the name of the field. This is in an IB window, by the way.
Does the AppleScript piece need to contain a “on launched” statement (or something like that), similar to how the buttons have a “on clicked” statement? Or does there need to be something special set in the “NSTextField Info” palette for the IB window?
If I understand correctly (and it seems to make sense) you want the information to be displayed when the application launches? If that’s the case, attach an “awake from nib” handler to the text field that will contain the information. In that handler, put the code to gather the information and update the text field (which will be “theObject” [by default] in this case).
I hope that made sense and I hope this helps,
Brad Bumgarner, CTA