我已经创建了一个“确认退出”对话框,用于在退出时提示用户。我已经成功地将它连接到“退出”菜单命令,但我还想将它连接到window-close (X)按钮。我该怎么做呢?我有一些使用Java Swing的经验,要完成这项任务,您必须向调用此提示符的框架添加一个窗口侦听器。这里有没有类似的事情我必须做?
发布于 2014-01-22 19:57:01
如下所示:
require 'fox16'
include Fox
class MyApp < FXMainWindow
def initialize(app)
@app = app
super(app, "Test", :height => 150, :width => 350, :opts=> DECOR_ALL)
self.connect(SEL_CLOSE, method(:on_close))
end
def create
super
show(PLACEMENT_SCREEN)
end
def on_close(sender, sel, event)
q = FXMessageBox.question(@app, MBOX_YES_NO, "Sure?", "You sure?")
if q == MBOX_CLICKED_YES
getApp().exit(0)
end
end
end
FXApp.new do |app|
MyApp.new(app)
app.create
app.run
end
https://stackoverflow.com/questions/17485188
复制相似问题