Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 3 - David Sponaas
In completing milestone 2, I had problems getting my menus to work. Originally, I was trying to use the CustomMenu class to get this done. My idea was that the user would be able to click on the morph I had created and a menu would pop up giving them options as to what action they would like to perform.
When implementing this with CustomMenu, however, I found that I was getting errors in the event handling. When I would tell Squeak to send all the events to my morph, it would send events that my morph would not know how to handle. Usually the program would fail after my morph received some sort of empty message, signified as '#'. When my morph did not know how to handle this message, execution would halt and an error thrown. In the end I did not fix this problem directly but isntead opted to work around it. I believe that the main reason that my first method was so problematic was that CustomMenu, as I later found out, is not a morphic class but is, instead, an MVC object.
Figuring that mixing MVC and morphic objects would probably be the source of my problems I decided instead to try and use a morphic menu object. For this reason I chose MenuMorph. The way the programmer interacts with MenuMorph is very similar to the way you would interact with any of the pluggable morph classes. After this, it was a simple matter of initializing the menu; declaring the targets, menu items, and menu actions; and then calling startUp on the menu to get it to appear in the world.
The method finder described here sounds awfully useful. When doing my own work, I generally just would take a look at the class and look through it to see if I could find the particular method that implemented a particular message. This approach is clearly lacking because it takes time to scan through a class looking for a particular method and if it is in a super class it takes even more time. The method finder shortcuts this process and directly tells you all implementing classes and methods.
Another useful thing I found out in reading other people's posts is how to pass arguments in events. I had been under the impression that this was impossible and that the programmer should simply find workarounds in a situation where parameters were to be passed in event handlers. Being to pass parameters directly certainly makes the process alot smoother.
Links to this Page