Sha256: 3e9c26b69b80d9e56133bad7ab81dabfcb0e6124945634ac2c61af4fa3c3eb99
Contents?: true
Size: 697 Bytes
Versions: 9
Compression:
Stored size: 697 Bytes
Contents
require 'ffi-tk' Tk.init command = lambda{ Tk::Bell.bell } menu = Tk::Menu.new(Tk.root) menu.add(:command, label: 'Example 1', command: command) menu.add(:command, label: 'Example 2', command: command) label = Tk::Label.new(Tk.root, text: 'Click me!').pack label.bind('<1>'){|event| Tk.popup(menu, event.x, event.y) } Tk::Button.new(Tk.root, text: 'Exit'){ exit }.pack Tk.mainloop __END__ # Create a menu set m [menu .popupMenu] $m add command -label "Example 1" -command bell $m add command -label "Example 2" -command bell # Create something to attach it to pack [label .l -text "Click me!"] # Arrange for the menu to pop up when the label is clicked bind .l <1> {tk_popup .popupMenu %X %Y}
Version data entries
9 entries across 9 versions & 1 rubygems