From 8cf53ab325402204165f1a543cdb0730e058ee57 Mon Sep 17 00:00:00 2001 From: Ronja Date: Sat, 31 Oct 2020 12:03:03 +0100 Subject: [PATCH] add event bandaid to slider and remove logging --- Luxe/blocks/ui/compass.wren | 4 ---- Luxe/blocks/ui/slider.wren | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Luxe/blocks/ui/compass.wren b/Luxe/blocks/ui/compass.wren index 7c2f021..b76ba19 100644 --- a/Luxe/blocks/ui/compass.wren +++ b/Luxe/blocks/ui/compass.wren @@ -36,21 +36,17 @@ class UiCompass{ Control.set_process(compass){|control, state, event, x,y,w,h| if(event.control != control) return - System.print("event: %(event) - currently captured: %(UI.get_captured(ent))") - if(event.type == UIEvent.press){ var relative_pos = AABB.new(x, y, w, h).relative_pos([event.x, event.y]) var inside = M.length(relative_pos.map{|comp| comp - 0.5}) < 0.5 if(inside) { state["pressed"] = true UI.capture(control) - System.print("CAPTURE COMPASS") } } if(event.type == UIEvent.release){ state["pressed"] = false UI.uncapture(control) - System.print("UNCAPTURE COMPASS") } if((event.type == UIEvent.move || event.type == UIEvent.press) && state["pressed"]){ var center = [x + w/2, y + h/2] diff --git a/Luxe/blocks/ui/slider.wren b/Luxe/blocks/ui/slider.wren index e27a6ce..33f2c71 100644 --- a/Luxe/blocks/ui/slider.wren +++ b/Luxe/blocks/ui/slider.wren @@ -9,6 +9,7 @@ import "globals" for Globals import "math/rect" for AABB import "math/math" for M import "blocks/debug" for DrawDebug +import "math/util" for Util class UiSlider{ static horizontal{"horiz"} @@ -50,6 +51,7 @@ class UiSlider{ } Control.set_process(slider){|control, state, event, x,y,w,h| if(event.control != control) return + if(!Util.valid_event(event)) return if(event.type == UIEvent.press){ state["pressed"] = true UI.capture(control)