forked from mbk-lab/rui_orig
2
0
Fork 0

Renamed "runFunc" to "callFunc"

This commit is contained in:
anoshenko 2022-11-02 20:10:19 +03:00
parent 8200f98d0d
commit 4e363d03a5
19 changed files with 54 additions and 54 deletions

View File

@ -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())
}
}

View File

@ -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)

View File

@ -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)

View File

@ -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 {

View File

@ -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)
}

View File

@ -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
}

View File

@ -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
}
}

View File

@ -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
}

View File

@ -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)
}
}

View File

@ -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)
}

View File

@ -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")

View File

@ -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())
}
}

View File

@ -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)
}

View File

@ -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())
}
}

View File

@ -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)
}

View File

@ -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)

View File

@ -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)
}
}

View File

@ -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() {

View File

@ -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