diff --git a/appWasm.go b/appWasm.go index 77ac069..f8bdccc 100644 --- a/appWasm.go +++ b/appWasm.go @@ -196,7 +196,7 @@ func (app *wasmApp) init(params AppParams) { body.Call("appendChild", div) if params.TitleColor != 0 { - app.brige.runFunc("setTitleColor", params.TitleColor.cssString()) + app.brige.callFunc("setTitleColor", params.TitleColor.cssString()) } } diff --git a/colorPicker.go b/colorPicker.go index 592a5bb..ceff060 100644 --- a/colorPicker.go +++ b/colorPicker.go @@ -113,7 +113,7 @@ func (picker *colorPickerData) set(tag string, value any) bool { func (picker *colorPickerData) colorChanged(oldColor Color) { if newColor := GetColorPickerValue(picker); oldColor != newColor { if picker.created { - picker.session.runFunc("setInputValue", picker.htmlID(), newColor.rgbString()) + picker.session.callFunc("setInputValue", picker.htmlID(), newColor.rgbString()) } for _, listener := range picker.colorChangedListeners { listener(picker, newColor) diff --git a/datePicker.go b/datePicker.go index e85e44c..ed799d1 100644 --- a/datePicker.go +++ b/datePicker.go @@ -97,7 +97,7 @@ func (picker *datePickerData) remove(tag string) { delete(picker.properties, DatePickerValue) date := GetDatePickerValue(picker) if picker.created { - picker.session.runFunc("setInputValue", picker.htmlID(), date.Format(dateFormat)) + picker.session.callFunc("setInputValue", picker.htmlID(), date.Format(dateFormat)) } for _, listener := range picker.dateChangedListeners { listener(picker, date) @@ -223,7 +223,7 @@ func (picker *datePickerData) set(tag string, value any) bool { if date, ok := setTimeValue(DatePickerValue); ok { if date != oldDate { if picker.created { - picker.session.runFunc("setInputValue", picker.htmlID(), date.Format(dateFormat)) + picker.session.callFunc("setInputValue", picker.htmlID(), date.Format(dateFormat)) } for _, listener := range picker.dateChangedListeners { listener(picker, date) diff --git a/downloadFile.go b/downloadFile.go index 80e81b2..c1a503a 100644 --- a/downloadFile.go +++ b/downloadFile.go @@ -23,7 +23,7 @@ func (session *sessionData) startDownload(file downloadFile) { currentDownloadId++ id := strconv.Itoa(currentDownloadId) downloadFiles[id] = file - session.runFunc("startDowndload", id, file.filename) + session.callFunc("startDowndload", id, file.filename) } func serveDownloadFile(id string, w http.ResponseWriter, r *http.Request) bool { diff --git a/dropDownList.go b/dropDownList.go index ead6587..8394a42 100644 --- a/dropDownList.go +++ b/dropDownList.go @@ -87,7 +87,7 @@ func (list *dropDownListData) remove(tag string) { delete(list.properties, Current) if oldCurrent != 0 { if list.created { - list.session.runFunc("selectDropDownListItem", list.htmlID(), 0) + list.session.callFunc("selectDropDownListItem", list.htmlID(), 0) } list.onSelectedItemChanged(0) } @@ -135,7 +135,7 @@ func (list *dropDownListData) set(tag string, value any) bool { if current := GetCurrent(list); oldCurrent != current { if list.created { - list.session.runFunc("selectDropDownListItem", list.htmlID(), current) + list.session.callFunc("selectDropDownListItem", list.htmlID(), current) } list.onSelectedItemChanged(current) } diff --git a/editView.go b/editView.go index 4981b06..897f890 100644 --- a/editView.go +++ b/editView.go @@ -136,7 +136,7 @@ func (edit *editViewData) remove(tag string) { if oldText != "" { edit.textChanged("") if edit.created { - edit.session.runFunc("setInputValue", edit.htmlID(), "") + edit.session.callFunc("setInputValue", edit.htmlID(), "") } } } @@ -210,7 +210,7 @@ func (edit *editViewData) set(tag string, value any) bool { if GetEditViewType(edit) == MultiLineText { updateInnerHTML(edit.htmlID(), edit.Session()) } else { - edit.session.runFunc("setInputValue", edit.htmlID(), text) + edit.session.callFunc("setInputValue", edit.htmlID(), text) } } } @@ -360,7 +360,7 @@ func (edit *editViewData) AppendText(text string) { if textValue, ok := value.(string); ok { textValue += text edit.properties[Text] = textValue - edit.session.runFunc("appendToInnerHTML", edit.htmlID(), text) + edit.session.callFunc("appendToInnerHTML", edit.htmlID(), text) edit.textChanged(textValue) return } diff --git a/filePicker.go b/filePicker.go index e9ae4a3..3e236f7 100644 --- a/filePicker.go +++ b/filePicker.go @@ -108,7 +108,7 @@ func (picker *filePickerData) LoadFile(file FileInfo, result func(FileInfo, []by for i, info := range picker.files { if info.Name == file.Name && info.Size == file.Size && info.LastModified == file.LastModified { picker.loader[i] = result - picker.Session().runFunc("loadSelectedFile", picker.htmlID(), i) + picker.Session().callFunc("loadSelectedFile", picker.htmlID(), i) return } } diff --git a/image.go b/image.go index 921b642..3ac985a 100644 --- a/image.go +++ b/image.go @@ -76,7 +76,7 @@ func (manager *imageManager) loadImage(url string, onLoaded func(Image), session image.listener = onLoaded image.loadingStatus = ImageLoading manager.images[url] = image - session.runFunc("loadImage", url) + session.callFunc("loadImage", url) return image } diff --git a/mediaPlayer.go b/mediaPlayer.go index 527686d..acb904d 100644 --- a/mediaPlayer.go +++ b/mediaPlayer.go @@ -472,7 +472,7 @@ func (player *mediaPlayerData) propertyChanged(tag string) { case Muted: value, _ := boolProperty(player, tag, player.session) - player.session.runFunc("setMediaMuted", player.htmlID(), value) + player.session.callFunc("setMediaMuted", player.htmlID(), value) case Preload: value, _ := enumProperty(player, tag, player.session, 0) @@ -655,15 +655,15 @@ func (player *mediaPlayerData) handleCommand(self View, command string, data Dat } func (player *mediaPlayerData) Play() { - player.session.runFunc("mediaPlay", player.htmlID()) + player.session.callFunc("mediaPlay", player.htmlID()) } func (player *mediaPlayerData) Pause() { - player.session.runFunc("mediaPause", player.htmlID()) + player.session.callFunc("mediaPause", player.htmlID()) } func (player *mediaPlayerData) SetCurrentTime(seconds float64) { - player.session.runFunc("mediaSetSetCurrentTime", player.htmlID(), seconds) + player.session.callFunc("mediaSetSetCurrentTime", player.htmlID(), seconds) } func (player *mediaPlayerData) getFloatPlayerProperty(tag string) (float64, bool) { @@ -694,7 +694,7 @@ func (player *mediaPlayerData) Duration() float64 { } func (player *mediaPlayerData) SetPlaybackRate(rate float64) { - player.session.runFunc("mediaSetPlaybackRate", player.htmlID(), rate) + player.session.callFunc("mediaSetPlaybackRate", player.htmlID(), rate) } func (player *mediaPlayerData) PlaybackRate() float64 { @@ -706,7 +706,7 @@ func (player *mediaPlayerData) PlaybackRate() float64 { func (player *mediaPlayerData) SetVolume(volume float64) { if volume >= 0 && volume <= 1 { - player.session.runFunc("mediaSetVolume", player.htmlID(), volume) + player.session.callFunc("mediaSetVolume", player.htmlID(), volume) } } diff --git a/numberPicker.go b/numberPicker.go index c094e98..551fe7c 100644 --- a/numberPicker.go +++ b/numberPicker.go @@ -116,7 +116,7 @@ func (picker *numberPickerData) set(tag string, value any) bool { if f, ok := floatProperty(picker, NumberPickerValue, picker.Session(), min); ok && f != oldValue { newValue, _ := floatTextProperty(picker, NumberPickerValue, picker.Session(), min) if picker.created { - picker.session.runFunc("setInputValue", picker.htmlID(), newValue) + picker.session.callFunc("setInputValue", picker.htmlID(), newValue) } for _, listener := range picker.numberChangedListeners { listener(picker, f) @@ -162,7 +162,7 @@ func (picker *numberPickerData) propertyChanged(tag string) { case NumberPickerValue: value := GetNumberPickerValue(picker) - picker.session.runFunc("setInputValue", picker.htmlID(), value) + picker.session.callFunc("setInputValue", picker.htmlID(), value) for _, listener := range picker.numberChangedListeners { listener(picker, value) } diff --git a/popup.go b/popup.go index 8715825..7288c5e 100644 --- a/popup.go +++ b/popup.go @@ -635,7 +635,7 @@ func (manager *popupManager) showPopup(popup Popup) { manager.popups = append(manager.popups, popup) } - session.runFunc("blurCurrent") + session.callFunc("blurCurrent") manager.updatePopupLayerInnerHTML(session) session.updateCSSProperty("ruiPopupLayer", "visibility", "visible") session.updateCSSProperty("ruiRoot", "pointer-events", "none") diff --git a/scrollEvent.go b/scrollEvent.go index 23522dc..3e630db 100644 --- a/scrollEvent.go +++ b/scrollEvent.go @@ -57,7 +57,7 @@ func ScrollViewTo(view View, subviewID string, x, y float64) { view = ViewByID(view, subviewID) } if view != nil { - view.Session().runFunc("scrollTo", view.htmlID(), x, y) + view.Session().callFunc("scrollTo", view.htmlID(), x, y) } } @@ -68,7 +68,7 @@ func ScrollViewToStart(view View, subviewID ...string) { view = ViewByID(view, subviewID[0]) } if view != nil { - view.Session().runFunc("scrollToStart", view.htmlID()) + view.Session().callFunc("scrollToStart", view.htmlID()) } } @@ -79,6 +79,6 @@ func ScrollViewToEnd(view View, subviewID ...string) { view = ViewByID(view, subviewID[0]) } if view != nil { - view.Session().runFunc("scrollToEnd", view.htmlID()) + view.Session().callFunc("scrollToEnd", view.htmlID()) } } diff --git a/session.go b/session.go index a615ce5..3d8e349 100644 --- a/session.go +++ b/session.go @@ -10,7 +10,7 @@ import ( type webBrige interface { startUpdateScript(htmlID string) bool finishUpdateScript(htmlID string) - runFunc(funcName string, args ...any) bool + callFunc(funcName string, args ...any) bool updateInnerHTML(htmlID, html string) appendToInnerHTML(htmlID, html string) updateCSSProperty(htmlID, property, value string) @@ -113,7 +113,7 @@ type Session interface { setBrige(events chan DataObject, brige webBrige) writeInitScript(writer *strings.Builder) - runFunc(funcName string, args ...any) + callFunc(funcName string, args ...any) updateInnerHTML(htmlID, html string) appendToInnerHTML(htmlID, html string) updateCSSProperty(htmlID, property, value string) @@ -350,9 +350,9 @@ func (session *sessionData) imageManager() *imageManager { return session.images } -func (session *sessionData) runFunc(funcName string, args ...any) { +func (session *sessionData) callFunc(funcName string, args ...any) { if session.brige != nil { - session.brige.runFunc(funcName, args...) + session.brige.callFunc(funcName, args...) } else { ErrorLog("No connection") } @@ -612,11 +612,11 @@ func (session *sessionData) handleEvent(command string, data DataObject) { func (session *sessionData) SetTitle(title string) { title, _ = session.GetString(title) - session.runFunc("setTitle", title) + session.callFunc("setTitle", title) } func (session *sessionData) SetTitleColor(color Color) { - session.runFunc("setTitleColor", color.cssString()) + session.callFunc("setTitleColor", color.cssString()) } func (session *sessionData) RemoteAddr() string { @@ -628,5 +628,5 @@ func (session *sessionData) OpenURL(urlStr string) { ErrorLog(err.Error()) return } - session.runFunc("openURL", urlStr) + session.callFunc("openURL", urlStr) } diff --git a/sessionUtils.go b/sessionUtils.go index 4da1e2d..bf3d977 100644 --- a/sessionUtils.go +++ b/sessionUtils.go @@ -12,7 +12,7 @@ func updateCSSStyle(htmlID string, session Session) { if view := session.viewByHTMLID(htmlID); view != nil { builder := viewCSSBuilder{buffer: allocStringBuilder()} view.cssStyle(view, &builder) - //session.runFunc("updateCSSStyle", view.htmlID(), builder.finish()) + //session.callFunc("updateCSSStyle", view.htmlID(), builder.finish()) session.updateProperty(view.htmlID(), "style", builder.finish()) } } diff --git a/tabsLayout.go b/tabsLayout.go index 18f55bf..0f48d90 100644 --- a/tabsLayout.go +++ b/tabsLayout.go @@ -151,7 +151,7 @@ func (tabsLayout *tabsLayoutData) remove(tag string) { return } if tabsLayout.created { - tabsLayout.session.runFunc("activateTab", tabsLayout.htmlID(), 0) + tabsLayout.session.callFunc("activateTab", tabsLayout.htmlID(), 0) for _, listener := range tabsLayout.tabListener { listener(tabsLayout, 0, oldCurrent) } @@ -235,7 +235,7 @@ func (tabsLayout *tabsLayoutData) set(tag string, value any) bool { return true } if tabsLayout.created { - tabsLayout.session.runFunc("activateTab", tabsLayout.htmlID(), current) + tabsLayout.session.callFunc("activateTab", tabsLayout.htmlID(), current) for _, listener := range tabsLayout.tabListener { listener(tabsLayout, current, oldCurrent) } diff --git a/timePicker.go b/timePicker.go index b997246..f809db1 100644 --- a/timePicker.go +++ b/timePicker.go @@ -97,7 +97,7 @@ func (picker *timePickerData) remove(tag string) { delete(picker.properties, TimePickerValue) time := GetTimePickerValue(picker) if picker.created { - picker.session.runFunc("setInputValue", picker.htmlID(), time.Format(timeFormat)) + picker.session.callFunc("setInputValue", picker.htmlID(), time.Format(timeFormat)) } for _, listener := range picker.timeChangedListeners { listener(picker, time) @@ -211,7 +211,7 @@ func (picker *timePickerData) set(tag string, value any) bool { if time, ok := setTimeValue(TimePickerValue); ok { if time != oldTime { if picker.created { - picker.session.runFunc("setInputValue", picker.htmlID(), time.Format(timeFormat)) + picker.session.callFunc("setInputValue", picker.htmlID(), time.Format(timeFormat)) } for _, listener := range picker.timeChangedListeners { listener(picker, time) diff --git a/viewUtils.go b/viewUtils.go index 34073bf..fd4765d 100644 --- a/viewUtils.go +++ b/viewUtils.go @@ -803,7 +803,7 @@ func colorStyledProperty(view View, subviewID []string, tag string, inherit bool // The focused View is the View which will receive keyboard events by default. func FocusView(view View) { if view != nil { - view.Session().runFunc("focus", view.htmlID()) + view.Session().callFunc("focus", view.htmlID()) } } @@ -811,21 +811,21 @@ func FocusView(view View) { // The focused View is the View which will receive keyboard events by default. func FocusViewByID(viewID string, session Session) { if viewID != "" { - session.runFunc("focus", viewID) + session.callFunc("focus", viewID) } } // BlurView removes keyboard focus from the specified View. func BlurView(view View) { if view != nil { - view.Session().runFunc("blur", view.htmlID()) + view.Session().callFunc("blur", view.htmlID()) } } // BlurViewByID removes keyboard focus from the View with the specified viewID. func BlurViewByID(viewID string, session Session) { if viewID != "" { - session.runFunc("blur", viewID) + session.callFunc("blur", viewID) } } diff --git a/wasmBrige.go b/wasmBrige.go index d2309d0..ac72bea 100644 --- a/wasmBrige.go +++ b/wasmBrige.go @@ -34,7 +34,7 @@ func (brige *wasmBrige) startUpdateScript(htmlID string) bool { func (brige *wasmBrige) finishUpdateScript(htmlID string) { } -func (brige *wasmBrige) runFunc(funcName string, args ...any) bool { +func (brige *wasmBrige) callFunc(funcName string, args ...any) bool { if ProtocolInDebugLog { text := funcName + "(" for i, arg := range args { @@ -52,23 +52,23 @@ func (brige *wasmBrige) runFunc(funcName string, args ...any) bool { } func (brige *wasmBrige) updateInnerHTML(htmlID, html string) { - brige.runFunc("updateInnerHTML", htmlID, html) + brige.callFunc("updateInnerHTML", htmlID, html) } func (brige *wasmBrige) appendToInnerHTML(htmlID, html string) { - brige.runFunc("appendToInnerHTML", htmlID, html) + brige.callFunc("appendToInnerHTML", htmlID, html) } func (brige *wasmBrige) updateCSSProperty(htmlID, property, value string) { - brige.runFunc("updateCSSProperty", htmlID, property, value) + brige.callFunc("updateCSSProperty", htmlID, property, value) } func (brige *wasmBrige) updateProperty(htmlID, property string, value any) { - brige.runFunc("updateProperty", htmlID, property, value) + brige.callFunc("updateProperty", htmlID, property, value) } func (brige *wasmBrige) removeProperty(htmlID, property string) { - brige.runFunc("removeProperty", htmlID, property) + brige.callFunc("removeProperty", htmlID, property) } func (brige *wasmBrige) close() { diff --git a/webBrige.go b/webBrige.go index bbc4dcb..1a88174 100644 --- a/webBrige.go +++ b/webBrige.go @@ -150,7 +150,7 @@ func (brige *wsBrige) argToString(arg any) (string, bool) { return "", false } -func (brige *wsBrige) runFunc(funcName string, args ...any) bool { +func (brige *wsBrige) callFunc(funcName string, args ...any) bool { brige.buffer.Reset() brige.buffer.WriteString(funcName) brige.buffer.WriteRune('(') @@ -179,11 +179,11 @@ func (brige *wsBrige) runFunc(funcName string, args ...any) bool { } func (brige *wsBrige) updateInnerHTML(htmlID, html string) { - brige.runFunc("updateInnerHTML", htmlID, html) + brige.callFunc("updateInnerHTML", htmlID, html) } func (brige *wsBrige) appendToInnerHTML(htmlID, html string) { - brige.runFunc("appendToInnerHTML", htmlID, html) + brige.callFunc("appendToInnerHTML", htmlID, html) } func (brige *wsBrige) updateCSSProperty(htmlID, property, value string) { @@ -194,7 +194,7 @@ func (brige *wsBrige) updateCSSProperty(htmlID, property, value string) { buffer.WriteString(value) buffer.WriteString("';\n") } else { - brige.runFunc("updateCSSProperty", htmlID, property, value) + brige.callFunc("updateCSSProperty", htmlID, property, value) } } @@ -208,7 +208,7 @@ func (brige *wsBrige) updateProperty(htmlID, property string, value any) { buffer.WriteString(");\n") } } else { - brige.runFunc("updateProperty", htmlID, property, value) + brige.callFunc("updateProperty", htmlID, property, value) } } @@ -220,7 +220,7 @@ func (brige *wsBrige) removeProperty(htmlID, property string) { buffer.WriteString(property) buffer.WriteString("');}\n") } else { - brige.runFunc("removeProperty", htmlID, property) + brige.callFunc("removeProperty", htmlID, property) } } @@ -367,7 +367,7 @@ func (brige *wsBrige) canvasTextMetrics(htmlID, font, text string) TextMetrics { answer := make(chan DataObject) brige.answer[answerID] = answer - if brige.runFunc("canvasTextMetrics", answerID, htmlID, font, text) { + if brige.callFunc("canvasTextMetrics", answerID, htmlID, font, text) { data := <-answer result.Width = dataFloatProperty(data, "width") } @@ -385,7 +385,7 @@ func (brige *wsBrige) htmlPropertyValue(htmlID, name string) string { answer := make(chan DataObject) brige.answer[answerID] = answer - if brige.runFunc("getPropertyValue", answerID, htmlID, name) { + if brige.callFunc("getPropertyValue", answerID, htmlID, name) { data := <-answer if value, ok := data.PropertyValue("value"); ok { return value