From 61ddf1a8a3d59df73fd656cbe319c779adf3e7fe Mon Sep 17 00:00:00 2001 From: Joe Williamson Date: Tue, 22 Aug 2017 06:08:42 -0700 Subject: [PATCH 1/3] adding CanvasBase.hx --- haxe/ui/backend/CanvasBase.hx | 98 +++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 haxe/ui/backend/CanvasBase.hx diff --git a/haxe/ui/backend/CanvasBase.hx b/haxe/ui/backend/CanvasBase.hx new file mode 100644 index 0000000..bbf0c6c --- /dev/null +++ b/haxe/ui/backend/CanvasBase.hx @@ -0,0 +1,98 @@ +package haxe.ui.backend; +import haxe.ui.backend.html5.EventMapper; +import haxe.ui.backend.html5.HtmlUtils; +import haxe.ui.backend.html5.StyleHelper; +import haxe.ui.backend.html5.UserAgent; +import haxe.ui.backend.html5.native.NativeElement; +import haxe.ui.core.UIEvent; + +import js.Browser; +import js.html.CanvasElement; +import js.html.DivElement; +import js.html.Element; +import js.html.MutationObserver; +import js.html.MutationRecord; +import js.html.Node; +import haxe.ui.components.VProgress; +import haxe.ui.containers.Header; +import haxe.ui.containers.ScrollView; +import haxe.ui.containers.TableView; +import haxe.ui.core.Component; +import haxe.ui.core.ImageDisplay; +import haxe.ui.core.MouseEvent; +import haxe.ui.core.Screen; +import haxe.ui.core.ScrollEvent; +import haxe.ui.core.TextDisplay; +import haxe.ui.core.TextInput; +import haxe.ui.core.UIEvent; +import haxe.ui.styles.Style; +import haxe.ui.components.TextArea; +import haxe.ui.components.Image; +import haxe.ui.core.KeyboardEvent; +import haxe.ui.components.TextField; +class CanvasBase extends haxe.ui.core.Component { + private static var _mutationObserver:MutationObserver; + private static var elementToComponent:Map = new Map(); + public function new() { + super(); + } + override public function handleCreate(native:Bool) {trace("create the damned canvas"); + var newElement = null; + if (native == true) { + var component:Component = cast(this, Component); + var nativeConfig:Map = component.getNativeConfigProperties(); + if (nativeConfig != null && nativeConfig.exists("class")) { + _nativeElement = Type.createInstance(Type.resolveClass(nativeConfig.get("class")), [this]); + _nativeElement.config = nativeConfig; + newElement = _nativeElement.create(); + } + + + if (newElement != null) { + newElement.style.position = "absolute"; + + if (element != null) { + var p = element.parentElement; + if (p != null) { + elementToComponent.remove(element); + p.replaceChild(newElement, element); + } + } + + element = newElement; + + remapEvents(); + } + } + + if (newElement == null) { + newElement = Browser.document.createElement("CANVAS"); + + newElement.style.setProperty("-webkit-touch-callout", "none"); + newElement.style.setProperty("-webkit-user-select", "none"); + newElement.style.setProperty("-khtml-user-select", "none"); + newElement.style.setProperty("-moz-user-select", "none"); + newElement.style.setProperty("-ms-user-select", "none"); + newElement.style.setProperty("user-select", "none"); + newElement.style.position = "absolute"; + + if (Std.is(this, Image)) { + newElement.style.boxSizing = "initial"; + } + + if (element != null) { + var p = element.parentElement; + if (p != null) { + elementToComponent.remove(element); + p.replaceChild(newElement, element); + } + } + + element = newElement; + elementToComponent.set(element, cast(this, Component)); + _nativeElement = null; + + remapEvents(); + } + } +} From 50c32f0ad777da987ceb1ea7bfae4b1445620a32 Mon Sep 17 00:00:00 2001 From: Joe Williamson Date: Thu, 14 Dec 2023 00:00:01 -0800 Subject: [PATCH 2/3] Update TextInputImpl.hx element.scrollHeight would sometimes return 0 and cause terminal loop issue. I never found repeat but this fixed my code --- haxe/ui/backend/TextInputImpl.hx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/haxe/ui/backend/TextInputImpl.hx b/haxe/ui/backend/TextInputImpl.hx index a16f59a..314d21f 100644 --- a/haxe/ui/backend/TextInputImpl.hx +++ b/haxe/ui/backend/TextInputImpl.hx @@ -142,7 +142,11 @@ class TextInputImpl extends TextDisplayImpl { _inputData.hscrollMax = element.scrollWidth - _width; _inputData.hscrollPageSize = (_width * _inputData.hscrollMax) / element.scrollWidth; - _inputData.vscrollMax = element.scrollHeight - _height; + if (element.scrollHeight != 0) { + _inputData.vscrollMax = element.scrollHeight - _height; + } else { + _inputData.vscrollMax = _textHeight - _height; + } _inputData.vscrollPageSize = (_height * _inputData.vscrollMax) / element.scrollHeight; } From 00199e487a4616528b242393f365ce426f143db4 Mon Sep 17 00:00:00 2001 From: Joe Williamson Date: Thu, 14 Dec 2023 00:05:21 -0800 Subject: [PATCH 3/3] cleaning stuff I never used --- haxe/ui/backend/CanvasBase.hx | 98 ----------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 haxe/ui/backend/CanvasBase.hx diff --git a/haxe/ui/backend/CanvasBase.hx b/haxe/ui/backend/CanvasBase.hx deleted file mode 100644 index bbf0c6c..0000000 --- a/haxe/ui/backend/CanvasBase.hx +++ /dev/null @@ -1,98 +0,0 @@ -package haxe.ui.backend; -import haxe.ui.backend.html5.EventMapper; -import haxe.ui.backend.html5.HtmlUtils; -import haxe.ui.backend.html5.StyleHelper; -import haxe.ui.backend.html5.UserAgent; -import haxe.ui.backend.html5.native.NativeElement; -import haxe.ui.core.UIEvent; - -import js.Browser; -import js.html.CanvasElement; -import js.html.DivElement; -import js.html.Element; -import js.html.MutationObserver; -import js.html.MutationRecord; -import js.html.Node; -import haxe.ui.components.VProgress; -import haxe.ui.containers.Header; -import haxe.ui.containers.ScrollView; -import haxe.ui.containers.TableView; -import haxe.ui.core.Component; -import haxe.ui.core.ImageDisplay; -import haxe.ui.core.MouseEvent; -import haxe.ui.core.Screen; -import haxe.ui.core.ScrollEvent; -import haxe.ui.core.TextDisplay; -import haxe.ui.core.TextInput; -import haxe.ui.core.UIEvent; -import haxe.ui.styles.Style; -import haxe.ui.components.TextArea; -import haxe.ui.components.Image; -import haxe.ui.core.KeyboardEvent; -import haxe.ui.components.TextField; -class CanvasBase extends haxe.ui.core.Component { - private static var _mutationObserver:MutationObserver; - private static var elementToComponent:Map = new Map(); - public function new() { - super(); - } - override public function handleCreate(native:Bool) {trace("create the damned canvas"); - var newElement = null; - if (native == true) { - var component:Component = cast(this, Component); - var nativeConfig:Map = component.getNativeConfigProperties(); - if (nativeConfig != null && nativeConfig.exists("class")) { - _nativeElement = Type.createInstance(Type.resolveClass(nativeConfig.get("class")), [this]); - _nativeElement.config = nativeConfig; - newElement = _nativeElement.create(); - } - - - if (newElement != null) { - newElement.style.position = "absolute"; - - if (element != null) { - var p = element.parentElement; - if (p != null) { - elementToComponent.remove(element); - p.replaceChild(newElement, element); - } - } - - element = newElement; - - remapEvents(); - } - } - - if (newElement == null) { - newElement = Browser.document.createElement("CANVAS"); - - newElement.style.setProperty("-webkit-touch-callout", "none"); - newElement.style.setProperty("-webkit-user-select", "none"); - newElement.style.setProperty("-khtml-user-select", "none"); - newElement.style.setProperty("-moz-user-select", "none"); - newElement.style.setProperty("-ms-user-select", "none"); - newElement.style.setProperty("user-select", "none"); - newElement.style.position = "absolute"; - - if (Std.is(this, Image)) { - newElement.style.boxSizing = "initial"; - } - - if (element != null) { - var p = element.parentElement; - if (p != null) { - elementToComponent.remove(element); - p.replaceChild(newElement, element); - } - } - - element = newElement; - elementToComponent.set(element, cast(this, Component)); - _nativeElement = null; - - remapEvents(); - } - } -}