# ap-dev:0447
# Writen by T Sakurai <tos-sakurai@secom.co.jp>
#
require 'phi'
include  Phi 

form1 = Form.new :form1, "Ctrl+Click to multi select"
listbox = ListBox.new form1
listbox.align = Phi::AL_CLIENT
listbox.multi_select = true

0.upto(5) {|i|
  listbox.items.add "listitem" + i.to_s
}

listbox.selected[0] = true
listbox.selected[3] = true
listbox.selected[5] = true

p listbox.selected[0]
p listbox.selected[1]
p listbox.selected_items

listbox.on_mouse_up = proc{
  form1.caption = "selected items = "+listbox.selected_items.inspect
}
listbox.on_key_up = proc{
  form1.caption = "selected items = "+listbox.selected_items.inspect
}

form1.show
Phi.mainloop

p listbox.selected_items
