diff --git a/inc/basic_widgets/core/error_helper.hpp b/inc/basic_widgets/core/error_helper.hpp index 737a5c3..6986c09 100644 --- a/inc/basic_widgets/core/error_helper.hpp +++ b/inc/basic_widgets/core/error_helper.hpp @@ -37,7 +37,7 @@ namespace bwidgets const std::string what {w == "unknown" ? SDL_GetError() : w}; if (code < 0) throw E(what); } - else if (success(code)) throw E(w); + else if (!success(code)) throw E(w.data()); return code; } diff --git a/src/core/font.cpp b/src/core/font.cpp index d9755cf..7e9c2eb 100644 --- a/src/core/font.cpp +++ b/src/core/font.cpp @@ -119,14 +119,9 @@ auto Font::find(const std::string_view pat) -> std::string "pattern parsing failed"), [](auto* ptr) { FcPatternDestroy(ptr); }); - // Don't check for error because it looks like it returns an error code when - // used with this way. But neverless things doesn't work well without - // calling it. - // TODO: get it to work properly! - /* success_or_throw( */ - FcConfigSubstitute((*conf)(), (*pattern)(), - FcMatchPattern); //, "FcConfigSubstitute failed", - /* [](auto code) { return code == FcFalse; }); */ + success_or_throw( + FcConfigSubstitute((*conf)(), (*pattern)(), FcMatchPattern), + "FcConfigSubstitute failed", [](auto code) { return code == FcTrue; }); return pattern; }(); diff --git a/src/w/feat/mouse_handler_impl.cpp b/src/w/feat/mouse_handler_impl.cpp index c5e2385..a87a6f6 100644 --- a/src/w/feat/mouse_handler_impl.cpp +++ b/src/w/feat/mouse_handler_impl.cpp @@ -29,9 +29,10 @@ void MouseHandlerImpl::enable_mouse_handler(const SDL_Rect& rel_area, _add_event_handler({SDL_MOUSEBUTTONUP, [this, mouse_in_rect](const SDL_Event& ev) { if (_pushed) { _on_push(_pushed = false); - _click_handler(ev.button); - if (mouse_in_rect({ev.button.x, ev.button.y})) + if (mouse_in_rect({ev.button.x, ev.button.y})) { focus(true); + _click_handler(ev.button); + } } }}); _add_event_handler({SDL_MOUSEMOTION, [this, mouse_in_rect](const SDL_Event& ev) {