Sha256: 9dce0d2546c656e73d7d933b57a1aaf63d128d884c091db0293c5b1a683eb430
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
require_relative './lib/wxapp_runner' class AppEventFilterTests < Test::Unit::TestCase class TestEvent < Wx::Event EVT_TEST_EVENT = Wx::EvtHandler.register_class(self, nil, 'evt_test_event', 0) def initialize(id=0) super(EVT_TEST_EVENT, id) end end class TestCmdEvent < Wx::CommandEvent EVT_TEST_CMD_EVENT = Wx::EvtHandler.register_class(self, nil, 'evt_test_cmd_event', 0) def initialize(id=0) super(EVT_TEST_CMD_EVENT, id) end end class TestFrame < Wx::Frame def initialize super(nil, size: [300,300]) @test_event = false @test_cmd_event = false evt_test_event { |evt| @test_event = true } evt_test_cmd_event { |evt| @test_cmd_event = true } end attr_reader :test_event, :test_cmd_event def reset @test_event = false @test_cmd_event = false end end module ::WxRuby module Test class App < Wx::App def filter_event(event) @filtered = true if event.is_a?(TestEvent) super end def filtered @filtered end def filtered=(f) @filtered = f end end end end def test_app_event_filter GC.start win = TestFrame.new win.event_handler.process_event(TestEvent.new) GC.start assert(Wx.get_app.filtered) Wx.get_app.filtered = false win.event_handler.process_event(TestCmdEvent.new) GC.start assert(!Wx.get_app.filtered) assert_nothing_raised { Wx::EvtHandler.clear_filters } GC.start win.event_handler.process_event(TestEvent.new) assert(Wx.get_app.filtered) GC.start end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wxruby3-0.9.0.pre.rc.3 | tests/test_app_event_filter.rb |
wxruby3-0.9.0.pre.rc.2 | tests/test_app_event_filter.rb |
wxruby3-0.9.0.pre.rc.1 | tests/test_app_event_filter.rb |