require 'phi'

include Phi

Phi::APPLICATION.create_handle

form = Form.new :form , "short_cut_enabled: Hit Ctrl+A - Ctrl+D or else"
$cnt = 0

def form.menu_job msg
  $cnt += 1
  self.caption = msg + " " + $cnt.to_s
end

p_menu = Phi.new_popup_menu form, :menu, [
  Phi.new_item_ex('Menu'      , ''  , :mi_menu , [
    Phi.new_item_ex('&A'    , 'Ctrl+A'  , proc{ form.menu_job "A" }),
    Phi.new_item_ex('&B'    , 'Ctrl+B'  , proc{ form.menu_job "B" }),
    Phi.new_item_ex('&C'    , 'Ctrl+C'  , proc{ form.menu_job "C" }),
    Phi.new_item_ex('&D'    , 'Ctrl+D'  , proc{ form.menu_job "D" }),
  ])
]

  
form.popup_menu = p_menu

button = Button.new form, :button, "change short_cut_enabled"
button.align = AL_CLIENT
button.on_click = proc{
  form.short_cut_enabled ^= true
  button.caption = "short_cut_enabled = #{form.short_cut_enabled}"
}

form.show
mainloop

