samples/hello/hello_menu_bar.rb in glimmer-dsl-tk-0.0.39 vs samples/hello/hello_menu_bar.rb in glimmer-dsl-tk-0.0.40

- old
+ new

@@ -36,10 +36,11 @@ font size: 50 anchor 'center' } menu { + # Mac-specific application menu (right next to the Apple menu) if OS.mac? menu(:application) { menu_item(:about, label: 'About My Application') { accelerator 'Command+A' @@ -62,25 +63,26 @@ end } } end + # Windows-specific system menu (to the top-left of the window frame) if OS.windows? menu(label: 'System') end menu(label: 'File', underline: 0) { menu_item(label: 'New', underline: 0) { - accelerator 'Command+N' + accelerator OS.mac? ? 'Command+N' : 'Control+N' on('command') do message_box(parent: r, title: 'New', message: 'New file created.') end } menu_item(label: 'Open...', underline: 0) { - accelerator 'Command+O' + accelerator OS.mac? ? 'Command+O' : 'Control+O' on('command') do message_box(parent: r, title: 'Open', message: 'Opening File...') end } @@ -108,19 +110,19 @@ } } menu(label: 'Edit', underline: 0) { menu_item(label: 'Cut', underline: 2) { - accelerator 'Command+X' + accelerator OS.mac? ? 'Command+X' : 'Control+X' } menu_item(label: 'Copy', underline: 0) { - accelerator 'Command+C' + accelerator OS.mac? ? 'Command+C' : 'Control+C' } menu_item(label: 'Paste', underline: 0) { - accelerator 'Command+V' + accelerator OS.mac? ? 'Command+V' : 'Control+V' } } menu(label: 'Options', underline: 0) { menu_item(:checkbutton, label: 'Enabled', underline: 0) { @@ -128,11 +130,11 @@ @select_one_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' } @select_multiple_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' } end } - @select_one_menu = menu(label: 'Select One', underline: 0) { + @select_one_menu = menu(label: 'Select One', underline: 7) { menu_item(:radiobutton, label: 'Option 1') { state 'disabled' } menu_item(:radiobutton, label: 'Option 2') { state 'disabled' @@ -140,11 +142,11 @@ menu_item(:radiobutton, label: 'Option 3') { state 'disabled' } } - @select_multiple_menu = menu(label: 'Select Multiple', underline: 0) { + @select_multiple_menu = menu(label: 'Select Multiple', underline: 7) { menu_item(:checkbutton, label: 'Option 4') { state 'disabled' } menu_item(:checkbutton, label: 'Option 5') { state 'disabled' @@ -162,11 +164,11 @@ image File.expand_path("images/#{image_name}.png", __dir__) } end } - menu(label: 'Language Name', underline: 3) { + menu(label: 'Country', underline: 3) { ['denmark', 'finland', 'france', 'germany', 'italy', 'mexico', 'netherlands', 'norway', 'usa'].each do |image_name| menu_item(:radiobutton, label: image_name.capitalize) { selection image_name == 'usa' image File.expand_path("images/#{image_name}.png", __dir__) compound 'left' @@ -196,53 +198,56 @@ } } menu(label: 'View', underline: 0) { menu_item(:radiobutton, label: 'Small', underline: 0) { - accelerator 'Command+S' + accelerator OS.mac? ? 'Command+S' : 'Control+S' on('command') do @label.font = {size: 25} end } menu_item(:radiobutton, label: 'Medium', underline: 0) { - accelerator 'Command+M' + accelerator OS.mac? ? 'Command+M' : 'Control+M' selection true on('command') do @label.font = {size: 50} end } menu_item(:radiobutton, label: 'Large', underline: 0) { - accelerator 'Command+L' + accelerator OS.mac? ? 'Command+L' : 'Control+L' on('command') do @label.font = {size: 75} end } } - menu(label: 'Window', underline: 0) + # Mac-specific window menu (containing zooming/resizing menu items) + menu(label: 'Window', underline: 0) if OS.mac? menu(label: 'Help', underline: 0) { - menu_item(:help) { - on('command') do - message_box(parent: r, title: 'Help', message: 'Help for my application.') - end - } + if OS.mac? + menu_item(:help) { + on('command') do + message_box(parent: r, title: 'Help', message: 'Help for my application.') + end + } + end menu_item(label: 'Manual', underline: 0) { - accelerator 'Command+Shift+M' + accelerator OS.mac? ? 'Command+Shift+M' : 'Control+U' on('command') do message_box(parent: r, title: 'Manual', message: 'Manual Contents') end } menu_item(label: 'Tutorial', underline: 0) { - accelerator 'Command+Shift+T' + accelerator OS.mac? ? 'Command+Shift+T' : 'Control+T' on('command') do message_box(parent: r, title: 'Tutorial', message: 'Tutorial Contents') end }