From b9291b4204b762425d0de8402bd8c7f1867b55f5 Mon Sep 17 00:00:00 2001 From: Martin Corino Date: Tue, 8 Oct 2024 17:21:19 +0200 Subject: [PATCH 1/2] add support for the missing #evt_hotkey method (WXMSW and WXOSX only) --- lib/wx/core/event.rb | 7 +++++++ lib/wx/doc/evthandler.rb | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/lib/wx/core/event.rb b/lib/wx/core/event.rb index 98eb85a8..3e88782a 100644 --- a/lib/wx/core/event.rb +++ b/lib/wx/core/event.rb @@ -58,4 +58,11 @@ class CommandEvent Wx::EVT_NC_PAINT, Wx::NcPaintEvent ] + if Wx.const_defined?(:EVT_HOTKEY) + EvtHandler.register_event_type EvtHandler::EventType[ + 'evt_hotkey', 1, + Wx::EVT_HOTKEY, + Wx::KeyEvent + ] + end end diff --git a/lib/wx/doc/evthandler.rb b/lib/wx/doc/evthandler.rb index 5f6c4edf..f6872a7e 100644 --- a/lib/wx/doc/evthandler.rb +++ b/lib/wx/doc/evthandler.rb @@ -142,6 +142,12 @@ def evt_timer(id, meth = nil, &block) end # @yield [*args] optional arguments def call_after(meth = nil, *args, &block) end + # Process a {Wx::EVT_HOTKEY} event. + # @param [Integer] id hotkey id + # @param [String,Symbol,Method,Proc] meth (name of) method or handler proc + # @yieldparam [Wx::KeyEvent] event the event to handle + def evt_hotkey(id, meth = nil, &block) end + end end From abdfef6d0ba49f8a58cccb49089262d4966b768d Mon Sep 17 00:00:00 2001 From: Martin Corino Date: Wed, 9 Oct 2024 09:09:59 +0200 Subject: [PATCH 2/2] remove useless catches --- tests/lib/leaked_overload_exception_test.rb | 2 +- tests/lib/overload_type_exception_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lib/leaked_overload_exception_test.rb b/tests/lib/leaked_overload_exception_test.rb index b4cc1c4d..e71d9f18 100644 --- a/tests/lib/leaked_overload_exception_test.rb +++ b/tests/lib/leaked_overload_exception_test.rb @@ -18,7 +18,7 @@ def test_exception_in_overload szr = ExceptionSizer.new(Wx::Orientation::VERTICAL) szr.add(Wx::Button.new(frame_win, name: 'button'), Wx::Direction::TOP) frame_win.sizer = szr - assert_raise_kind_of(RuntimeError) { frame_win.layout } + frame_win.layout frame_win.sizer = nil end diff --git a/tests/lib/overload_type_exception_test.rb b/tests/lib/overload_type_exception_test.rb index 54a9271a..0df3fdeb 100644 --- a/tests/lib/overload_type_exception_test.rb +++ b/tests/lib/overload_type_exception_test.rb @@ -18,7 +18,7 @@ def test_invalid_output szr = InvalidOutputSizer.new(Wx::Orientation::VERTICAL) szr.add(Wx::Button.new(frame_win, name: 'button'), Wx::Direction::TOP) frame_win.sizer = szr - assert_raise_kind_of(TypeError) { frame_win.layout } + frame_win.layout frame_win.sizer = nil end