Saturday, November 29, 2008

Glimmer List Box Single-Selection Data-Binding

I added data-binding support for List boxes.

class Person
attr_accessor :country, :country_options

def initialize
self.country_options=["", "Canada", "US", "Mexico"] = "Canada"

class HelloList
include Glimmer
def launch
shell {
list {
selection bind(, :country)

This produces a tiny shell with a list box that has "Canada" preselected:

This works pretty much like >>Combo box data-binding<<.

By default, List boxes allow single selection. In order to create a multi-selection list that enables users to hold the shift button and select multiple items, you would pass the "SWT::MULTI" constant (e.g. "list(SWT::MULTI) {...} or "list(:multi) {...}")

Stay tuned for my post on multi-selection data-binding support, which will allow binding selection to an array property on the model.

No comments: