Send to Printer

st4u

ST 4U 108: Finishing the CounterView UI in WB Pro

July 18, 2011 9:27:21.648

Today's Smalltalk 4 You continues the brief tutorial on WindowBuilder Pro, by hooking up a domain object to the UI we painted last time. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

WB Pro.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll continue our introduction to WindowBuilder pro in VA Smalltalk. Last time we painted the UI - today, we'll hook the UI we painted up to the simple Counter application we built awhile ago.

To refresh a bit, here's the simple UI we built - an input field for the current value, and a button to increment the value:

Simple UI

One thing we didn't do is hook the button up to any behavior. To do that, we need to define a callback - a SMalltalk method that will be invoked when the button is pressed:

Define Callback

You can doa number of things in the callback definition UI, but we're going to take the simplest tack: hook up a callback for when the button is pressed:

Defining the Callback

Go back to the browser and look at the code that got generated again - you should notice a new section for the callback:

Callback specified

Now we'll getinto hooking the UI up to a domain object. We'll define an instance variable in the UI to hold the domain object, and instantiate it in the initialize method:

Set up the domain

Next, we'll set up the callback method to use the domain object when the button is pressed. To update the input field, we need to grab it by name using #widgetNamed:, and then use the #value: message to set the value into it:

Set up the Functionality

Finally, we can test the UI. Open it up and you should see the input field incrementing when you press the button:

Working UI

That's it - we've created a simple UI that hooks up to a domain object, and updates the state of the domain based on UI actions. With that, you should be able to get started building more useful things with WindowBuilder Pro!

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , , ,

Enclosures:
[st4u108-iPhone.m4v ( Size: 8948589 )]

 Share Tweet This