Where I'm hung up is how/where to accomplish the following:
1. Display a blank card on opening the deck.
2. Populate the list control based on the cards already in the deck.
3. Do the actual card selection/display based on clicking the name in the list.
There are probably dozens of different ways to do this and what I'm going to suggest isn't really the best way, but it might be the easiest way when you're just starting out. Like Craig, I congratulate you on choosing a simple project to begin with, it's exactly the best way to proceed.
I would create a group that contains all the controls in your diagram. Set the group to act like a background in the property inspector. That way it will appear on every card. Name it something, I'll call it "template".
The fields in the group should not be set to share their text (the sharedText property is false.) You can set that in the field property inspector. This makes each field contain text unique to each card. The one exception should be the list field, which
should share its content. (I'd probably make the list its own separate group, but for now it doesn't matter.) Name the list field something; I'll use "list".
When the stack opens, run a preOpenStack handler (put it into the stack script) that puts empty into each field and puts the names of all the cards into the list:
Code: Select all
on preOpenStack
repeat with x = 1 to the number of fields in group "template"
put empty into field x of group "template"
end repeat
put the cardnames of this stack into field "list"
end preOpenStack
When the stack opens, you should see an empty template that contains only the list of card names. Until you have some content, the list will contain only one line and it will begin with "card id xxxx". You can fix this later, leave it for now.
Rather than a Close button, I'd use a Save button. When the user clicks it, it will name the card for the first and last name fields, add that name to the list, and save the stack:
Code: Select all
on mouseUp -- script of Save button
set the name of this card to (field "first name" && field "last name")
put the cardnames of this stack into field "list"
save this stack
end mouseUp
The script of the list field can be like this:
Code: Select all
on mouseUp
get the text of the hilitedline of me
go card it
end mouseUp
I'd also add a New button, otherwise this example will always only have a single card. The script of the New button:
Code: Select all
on mouseUp
create card
end mouseUp
This will add a new card with empty fields, ready to type into.
That should get you started. See if you can figure out how to remove the single unnamed card in the list when the app has no content yet. Also for this method, you don't need an Edit button. The user can just click Save after changing the content.
The Cancel button would have to delete the currently unnamed card. See if you can figure out how to decide whether the card hasn't been saved yet.
Once you have this working, I'd move on to a different method of doing the same thing, which would involve storing the data entries as custom properties of the stack and using only a single card to display the user's choice (this will likely get you into using arrays.) This will be a little more complex.
And once that is done, you might want to experiment with using a database to store the content and loading the user entries into a single template card from there. I'm not sure I'd use a database for an address book where there the amount of data isn't usually very large, but it would be another way to learn more.