From cdf5533d389903d60bedc9d1acd5cba22435b52b Mon Sep 17 00:00:00 2001 From: drug007 Date: Sun, 2 Oct 2022 16:46:48 +0300 Subject: [PATCH] Fixed bugs keyboard input enabled again, slider compilation error fixed --- source/nanogui/sdlapp.d | 2 +- source/nanogui/sdlbackend.d | 5 +++++ source/nanogui/slider.d | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/nanogui/sdlapp.d b/source/nanogui/sdlapp.d index b9ffd7ba..7f46156b 100644 --- a/source/nanogui/sdlapp.d +++ b/source/nanogui/sdlapp.d @@ -127,7 +127,7 @@ class SdlApp } auto onResize() { return _onResize; } - alias OnKeyboardChar = void delegate(dchar ch); + alias OnKeyboardChar = bool delegate(dchar ch); private OnKeyboardChar _onKeyboardChar; void onKeyboardChar(OnKeyboardChar handler) { diff --git a/source/nanogui/sdlbackend.d b/source/nanogui/sdlbackend.d index bee5c63e..4e09fdd1 100644 --- a/source/nanogui/sdlbackend.d +++ b/source/nanogui/sdlbackend.d @@ -144,6 +144,11 @@ class SdlBackend : Screen return super.mouseButtonCallbackEvent(btn, action, modifiers, Clock.currTime.stdTime); }; + _sdlApp.onKeyboardChar = delegate(dchar codepoint) + { + return keyboardCharacterEvent(codepoint); + }; + _sdlApp.onClose = () { if (_onClose) diff --git a/source/nanogui/slider.d b/source/nanogui/slider.d index d474d105..c9a132a8 100644 --- a/source/nanogui/slider.d +++ b/source/nanogui/slider.d @@ -13,7 +13,7 @@ import std.algorithm : min, max; import arsd.nanovega; import nanogui.widget : Widget; import nanogui.common : Vector2i, MouseButton, Color, boxGradient, - fillColor, Vector2f, radialGradient, linearGradient; + fillColor, Vector2f, radialGradient, linearGradient, NanoContext; /// Fractional slider widget with mouse control class Slider(T) : Widget { @@ -170,7 +170,7 @@ public: return true; } - override void draw(NanoContext ctx) + override void draw(ref NanoContext ctx) { Vector2f center = cast(Vector2f) mPos + 0.5f * cast(Vector2f) mSize; float kr = cast(int) (mSize.y * 0.4f);