#!/usr/bin/env lua
lgi = require('lgi')
gtk = lgi.require('Gtk', '3.0')
gdk = lgi.require('Gdk', '3.0')
local window, viewbox
local function add_some_tabs()
for i = 1, 3 do
local page = gtk.Label {
label = "This is page " .. i ..
"\nWhy not right-click on a tab?"
}
page:show_all()
local label = gtk.EventBox { gtk.Label { label = "Page " .. i }}
label:show_all()
viewbox:append_page(page, label)
viewbox:show_all()
local widget = viewbox:get_tab_label(page)
local window = widget:get_window()
local events = window:get_events()
events.BUTTON_PRESS_MASK = true
events.BUTTON_RELEASE_MASK = true
window:set_events(events)
widget._on_button_press_event_ = function(widget, event)
print("on_button_press_event", event)
--if event:triggers_context_menu() then
if gdk.Event.triggers_context_menu(event) then
print("show menu")
end
end
end
end
window = gtk.Window {
title = "Window",
type = gtk.WindowType.TOPLEVEL,
decorated = true, resizable = true,
width = 400, height = 400,
_on_destroy_ = function() os.exit(0) end,
gtk.Box {
orientation = 'VERTICAL',
expand = true,
visible = true,
gtk.Button {
label = "Click Me",
_on_clicked_ = add_some_tabs,
},
gtk.Notebook {
id = 'viewbox',
expand = true,
visible = true,
show_tabs = true,
show_border = false,
enable_popup = false,
scrollable = true,
},
}
}
viewbox = window.child.viewbox
window:show_all()
gtk.main()
--
Sent from my Game Boy.