Skip to main content

Learning by tearing things apart

Daniel Klein posted to the Squeak Beginners list:

I'm currently reading the 'Squeak by Example' book with the goal of being able to do some Morphic stuff.

Anyway, I get the impression that everything in the image at my fingertips. So what if I want to add something to one of the context menus, or find out what message gets sent to invoke a menu entry so that I can run it directly in a workspace, or change the order of the objects in one of the flaps, etc.

What are the steps to go about finding out where this stuff is in the image?

One of the neat things about Morphic is that you can tear it apart while it is running. This can give you some clues as to how a GUI was built. Note that the image is built by direct manipulation as well as by code. If you move a window and then save the image, the window will be where you left it. But, you won't be able to find the code that moved the window to that location because there isn't any.

But, most GUIs in Squeak are built with Smalltalk code, not with direct manipulation.

One of my favorite things to show a new Squeaker is that they can Alt+Shift click on the World menu to bring up a halo on a menu item (Alt+Clicking will let you drill into a GUI, Alt goes backward which usually gets to the menu or icon directly and bypasses all of the alignment morphs.)



I then click on the debug halo and look at an explorer.

This tells me that the Menu Item calls #doMenuItem:with: and passes two arguments. TheWorldMenu and another selector helpDo.

I can then start browsing implementors and senders. I think helpDo is the more interesting implementation and leads me quickly to helpMenu.

doMenuItem:with: is the more interesting sender. It takes me to fillIn:from: and then senders there takes me to I think what you are looking for (I see my CSS is cropping the pic, click to see the whole thing).


Comments

Popular posts from this blog

Refactoring – Ruby Ed.

The original Refactoring book by Martin Fowler had a big impact on how I thought about writing software. I’d used the refactoring tools in Smalltalk, but the book changed the way I thought about refactoring and gave names to many new refactorings. This Ruby edition of the book is highly anticipated. I received my copy at a drawing in our local Ruby user’s group. Part of the deal was you had to write a review (you are reading it) in exchange for the book. Nearly everyone at the meeting wanted a crack at the book. The authors suggest that if you have the original work, you probably shouldn’t purchase this new edition. I don’t agree. There is plenty of new content with around 20 new refactorings and a few new code smells to make the difference worthwhile. There is a tremendous amount of thoughtful Ruby code snippets inserted throughout the text. In fact, this is one of those books that is great for everyone on a team to have a copy. It is the kind of book that can be used to raise t...

Hands-on Microformats: Quickly build an hCalendar-based view with XSLT and Seaside

I gave a talk with the title, "Hands-on Microformats: Quickly build an hCalendar-based view" at the 2009 BarCamp Omaha . Since the presentation was really looking at code, I didn't have a slide deck. So I thought I would share my notes in a series of posts. This is the first. Short version: By adding a few specific attributes and abiding by some date formatting rules, you can generate a great-looking monthly calendar with surprisingly little effort. That is, get something like this: From HTML that looks like this: A microformat lets you use standard XHTML but add in some semantic goodness without resorting to a separate XML namespace and corresponding set of tags (or formally, an XML application ). For our example, hCalendar uses a 1:1 representation of standard iCalendar ( RFC2445 ) VEVENT properties and values in semantic XHTML . hCalendar wouldn't have caught my attention if it weren't for js-hCalendar . This bit of JavaScript created by David Glasser and ho...

JavaScript as Assembly – Exploring CoffeeScript & Dart

Just agreed to a talk on Monday, June 18 for UpFront KC . Here is a quick summary: JavaScript as Assembly – Exploring CoffeeScript & Dart JavaScript can be both awesome and terrible. We’ll talk about the history of generating JavaScript and then work through some quick exercises in two languages that can produce JavaScript as output: CoffeeScript and Dart. Then, we’ll compare the two and look where they are headed. This is an interactive talk, so plan to bring a laptop and code along. At the end, you'll at least have run a bit of CoffeeScript and Dart. You don’t have to be an experienced developer, as we’ll keep it super-high level. About your presenter: By day, David Mitchell is a mild mannered Group Technical Director at VML , where he is more likely to review JavaScript code than write it. By night, David is a polygot programmer, exploring languages like JavaScript, Smalltalk, and Lisp. David has presented nationally and at regional conferences and has ...