Monday, July 30, 2007

Attainable Goals

Well, it didn't take long for me to stop programming daily. Spent Friday on a major Guitar Hero binge, and then just didn't do any on Saturday. So, I think I'm going to shift to weekly goals, and work in what I can.

I didn't spend a lot of time on the program on Sunday, but what I did do was worthwhile. All of my buttons now work. (Earlier post has pictures of the interface) Add, Edit, Delete...they all do their jobs now. I found a couple places where I need to add in some error handling, but the base functionality is there. Yay!

I spent some time futzing with the Pop-up menu for gas type selection (regular, premium, etc.). It took me forever to figure out how to get more than 3 items (the default) to appear in the list. Regular, medium, premium, diesel is four, plus I think some people use race gas occasionally, so that's five. The properties form did not give me the option to change the number of items (irritating!). I did some searching around, and didn't find any references to it. Then I finally paid attention to the documentation that said the principal attribute of an NSPopUpButton is an NSMenu. This made me remember an exercise from class where we added an item to a pull-down menu by dragging out a "Menu Item" and adding it to the menu. I tried that, and it did indeed work. So now I can successfully pull the information out of the pop-up and store that with the tank info. But I haven't yet figured out how to set the pop-up to be a particular value. If someone chooses to edit a tank, I want the pop-up to be set to whatever value the tank already is. And eventually, I'd like to provide a preference setting allowing the user to choose a default grade. Either way, I need to be able to set that menu, and doing so will be my next step.

That screen shot shows the entry window with an "Add Tank" button. Since taking that picture, I changed my mind about how this will work. I'm using this same form for both "New" and "Edit." So I changed the "Add Tank" button to simply "Done," and then programmatically (is that a word?) set the values that should be displayed when the form opens. If it's a new tank, the date defaults to today, and all other fields are blank. If the tank is being edited, it supplies the values from the existing tank. The "Reset Values" button is disabled when creating a new tank (what's the point?), and replaces the existing tank values when editing a tank. I basically created a variable, and depending on which button I hit, new or edit, it sets a particular value for that variable. Then each action in the form will react according to that variable. I need to play with this some more, because it felt like a hack. What I really wanted to do was something along the lines of "If (clickedButton == New) {} else if (clickedButton == Edit) {}" or something like that. I couldn't quite figure out where to determine that information. What I have works, so it's not a huge deal, but I can't help thinking there is a more elegant way of pulling this off. The other thing I want to do is, for a new tank, disable the Done button until all three text fields have values, at which point the Done buttons enables and becomes the default (hit enter key) button. I haven't figured out how to do that yet.

So, goals for the week. I may change my mind, but right now what I would like to have in place by next weekend is 1) saving, and 2) undo. Since I have the edit functionality working, undo is less of an issue for me, but it would still be nice to have. The reason I may change my mind is that there is still some additional information I want presented on the main screen (overall average MPG, total cost of fuel, etc), and I may decide to focus on that instead. I have some ideas, but I don't envision them being easy to do.

No comments: