From 7d4b90769fc65e1d81f44bc595783edcbbb70ae1 Mon Sep 17 00:00:00 2001 From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:06:59 +0200 Subject: [PATCH] Bug fixing --- CHANGELOG.md | 2 +- detailsView.go | 4 +-- keyEvents.go | 30 ---------------------- listLayout.go | 8 ------ mouseEvents.go | 44 -------------------------------- pointerEvents.go | 39 ---------------------------- radius.go | 4 +-- touchEvents.go | 39 ---------------------------- viewTransform.go => transform.go | 0 9 files changed, 5 insertions(+), 165 deletions(-) rename viewTransform.go => transform.go (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e028774..615a4ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # v0.18.0 * Property name type changed to PropertyName. -* Transform interface renamed to TransformProperty. TransformTag constant renamed to Transform. +* Transform interface renamed to TransformProperty. NewTransform function renamed to NewTransformProperty. TransformTag constant renamed to Transform. * OriginX, OriginY, and OriginZ properties renamed to TransformOriginX, TransformOriginY, and TransformOriginZ * GetOrigin function renamed to GetTransformOrigin * Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin. diff --git a/detailsView.go b/detailsView.go index cb6529f..b229bc0 100644 --- a/detailsView.go +++ b/detailsView.go @@ -142,9 +142,9 @@ func (detailsView *detailsViewData) htmlSubviews(self View, buffer *strings.Buil buffer.WriteString("") case View: - buffer.WriteString("") + buffer.WriteString(`
`) viewHTML(value, buffer) - buffer.WriteString("
") + buffer.WriteString("
") } } diff --git a/keyEvents.go b/keyEvents.go index 5f1e810..97d6b68 100644 --- a/keyEvents.go +++ b/keyEvents.go @@ -429,36 +429,6 @@ func (event *KeyEvent) init(data DataObject) { event.MetaKey = getBool("metaKey") } -/* -func setKeyListener(properties Properties, tag PropertyName, value any) bool { - if listeners, ok := valueToOneArgEventListeners[View, KeyEvent](value); ok { - if len(listeners) == 0 { - properties.setRaw(tag, nil) - } else { - properties.setRaw(tag, listeners) - } - return true - } - notCompatibleType(tag, value) - return false -} - -func (view *viewData) removeKeyListener(tag PropertyName) { - delete(view.properties, tag) - if view.created { - switch tag { - case KeyDownEvent: - if !view.Focusable() { - view.session.removeProperty(view.htmlID(), "onkeydown") - } - - case KeyUpEvent: - view.session.removeProperty(view.htmlID(), "onkeyup") - } - } -} -*/ - func keyEventsHtml(view View, buffer *strings.Builder) { if len(getOneArgEventListeners[View, KeyEvent](view, nil, KeyDownEvent)) > 0 { buffer.WriteString(`onkeydown="keyDownEvent(this, event)" `) diff --git a/listLayout.go b/listLayout.go index 0a479f3..9ad7642 100644 --- a/listLayout.go +++ b/listLayout.go @@ -37,7 +37,6 @@ type ListLayout interface { // UpdateContent updates child Views if the "content" property value is set to ListAdapter, // otherwise does nothing UpdateContent() - setAdapter(ListAdapter) } type listLayoutData struct { @@ -169,13 +168,6 @@ func (listLayout *listLayoutData) htmlSubviews(self View, buffer *strings.Builde } } -func (listLayout *listLayoutData) setAdapter(adapter ListAdapter) { - listLayout.adapter = adapter - if adapter != nil { - listLayout.createContent() - } -} - func (listLayout *listLayoutData) createContent() bool { if adapter := listLayout.adapter; adapter != nil { listLayout.views = []View{} diff --git a/mouseEvents.go b/mouseEvents.go index 836e5c7..e338fca 100644 --- a/mouseEvents.go +++ b/mouseEvents.go @@ -228,50 +228,6 @@ type MouseEvent struct { MetaKey bool } -/* -func setMouseListener(properties Properties, tag PropertyName, value any) bool { - if listeners, ok := valueToOneArgEventListeners[View, MouseEvent](value); ok { - if len(listeners) == 0 { - properties.setRaw(tag, nil) - } else { - properties.setRaw(tag, listeners) - } - return true - } - notCompatibleType(tag, value) - return false -} - -func (view *viewData) removeMouseListener(tag PropertyName) { - delete(view.properties, tag) - if view.created { - if js, ok := eventJsFunc[tag]; ok { - view.session.removeProperty(view.htmlID(), js.jsEvent) - } - } -} - -func mouseEventsHtml(view View, buffer *strings.Builder, hasTooltip bool) { - for _, tag := range []PropertyName{ClickEvent, DoubleClickEvent, MouseDown, MouseUp, MouseMove, MouseOut, MouseOver, ContextMenuEvent} { - if value := view.getRaw(tag); value != nil { - if js, ok := eventJsFunc[tag]; ok { - if listeners, ok := value.([]func(View, MouseEvent)); ok && len(listeners) > 0 { - buffer.WriteString(js.jsEvent) - buffer.WriteString(`="`) - buffer.WriteString(js.jsFunc) - buffer.WriteString(`(this, event)" `) - } - } - } - } - - if hasTooltip { - buffer.WriteString(`onmouseenter="mouseEnterEvent(this, event)" `) - buffer.WriteString(`onmouseleave="mouseLeaveEvent(this, event)" `) - } -} -*/ - func getTimeStamp(data DataObject) uint64 { if value, ok := data.PropertyValue("timeStamp"); ok { if index := strings.Index(value, "."); index > 0 { diff --git a/pointerEvents.go b/pointerEvents.go index c4d33a3..3d42cb8 100644 --- a/pointerEvents.go +++ b/pointerEvents.go @@ -154,45 +154,6 @@ type PointerEvent struct { IsPrimary bool } -/* -func setPointerListener(properties Properties, tag PropertyName, value any) bool { - if listeners, ok := valueToOneArgEventListeners[View, PointerEvent](value); ok { - if len(listeners) == 0 { - properties.setRaw(tag, nil) - } else { - properties.setRaw(tag, listeners) - } - return true - } - notCompatibleType(tag, value) - return false -} - -func (view *viewData) removePointerListener(tag PropertyName) { - delete(view.properties, tag) - if view.created { - if js, ok := eventJsFunc[tag]; ok { - view.session.removeProperty(view.htmlID(), js.jsEvent) - } - } -} - -func pointerEventsHtml(view View, buffer *strings.Builder) { - for _, tag := range []PropertyName{PointerDown, PointerUp, PointerMove, PointerOut, PointerOver, PointerCancel} { - if value := view.getRaw(tag); value != nil { - if js, ok := eventJsFunc[tag]; ok { - if listeners, ok := value.([]func(View, PointerEvent)); ok && len(listeners) > 0 { - buffer.WriteString(js.jsEvent) - buffer.WriteString(`="`) - buffer.WriteString(js.jsFunc) - buffer.WriteString(`(this, event)" `) - } - } - } - } -} -*/ - func (event *PointerEvent) init(data DataObject) { event.MouseEvent.init(data) diff --git a/radius.go b/radius.go index 5ddb2c1..7352632 100644 --- a/radius.go +++ b/radius.go @@ -624,8 +624,8 @@ func radiusPropertySet(radius Properties, tag PropertyName, value any) []Propert case string: if strings.Contains(value, "/") { if values := strings.Split(value, "/"); len(values) == 2 { - if result = radiusPropertySet(radius, tag+"-x", value[0]); result != nil { - if resultY := radiusPropertySet(radius, tag+"-y", value[1]); resultY != nil { + if result = radiusPropertySet(radius, tag+"-x", values[0]); result != nil { + if resultY := radiusPropertySet(radius, tag+"-y", values[1]); resultY != nil { result = append(result, resultY...) } diff --git a/touchEvents.go b/touchEvents.go index 1b55ea0..93230c2 100644 --- a/touchEvents.go +++ b/touchEvents.go @@ -142,45 +142,6 @@ type TouchEvent struct { MetaKey bool } -/* -func setTouchListener(properties Properties, tag PropertyName, value any) bool { - if listeners, ok := valueToOneArgEventListeners[View, TouchEvent](value); ok { - if len(listeners) == 0 { - properties.setRaw(tag, nil) - } else { - properties.setRaw(tag, listeners) - } - return true - } - notCompatibleType(tag, value) - return false -} - -func (view *viewData) removeTouchListener(tag PropertyName) { - delete(view.properties, tag) - if view.created { - if js, ok := eventJsFunc[tag]; ok { - view.session.removeProperty(view.htmlID(), js.jsEvent) - } - } -} - -func touchEventsHtml(view View, buffer *strings.Builder) { - for _, tag := range []PropertyName{TouchStart, TouchEnd, TouchMove, TouchCancel} { - if value := view.getRaw(tag); value != nil { - if js, ok := eventJsFunc[tag]; ok { - if listeners, ok := value.([]func(View, TouchEvent)); ok && len(listeners) > 0 { - buffer.WriteString(js.jsEvent) - buffer.WriteString(`="`) - buffer.WriteString(js.jsFunc) - buffer.WriteString(`(this, event)" `) - } - } - } - } -} -*/ - func (event *TouchEvent) init(data DataObject) { event.Touches = []Touch{} diff --git a/viewTransform.go b/transform.go similarity index 100% rename from viewTransform.go rename to transform.go