Ralf Fassel wrote:
…I think the TCL-idiom to prevent
windows/applications being destroyed by the decoration buttons is to
use the `wm’ command, like this:wm protocol {.} WM_DELETE_WINDOW my_deletion_prevention_routine
Binding to the
destroy' event is too late, things have happened already when this triggers. See the
wm’ manpage for details.
Tk Built-In Commands - wm manual page
Great; that leads here:
require ‘tk’
top = TkRoot.new()
canvas = TkCanvas.new(top) {width(400);height(300) }
TkcText.new(canvas, 100, 200) { text ‘hello world’ }
canvas.grid
top.protocol(‘WM_DELETE_WINDOW’, proc{puts ‘huh?’})
Tk.mainloop
canvas = TkCanvas.new() {width(400); height(300) }
TkcText.new(canvas, 200, 100) { text ‘hello world’ }
canvas.grid
Tk.mainloop
But what’s “my_deletion_prevention_routine”? The documentation lists several
“Tk.quit” and “callback_break” routines. Tk.quit does not seem to exist (in
Ruby), and callback_break creates the error “Tk callback returns ‘break’
status”