mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
Potential solution for getting the calling window of a bound method.
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -80,6 +79,7 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter,
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.WithoutCancel(r.Context()))
|
||||
ctx = context.WithValue(ctx, "window", window)
|
||||
|
||||
ambiguousID := false
|
||||
m.l.Lock()
|
||||
@@ -105,12 +105,9 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter,
|
||||
m.l.Unlock()
|
||||
}()
|
||||
|
||||
// Check if the first or second bound method parameter is a Window interface
|
||||
// Check if the first bound method parameter is a Window interface
|
||||
if len(boundMethod.Inputs) > 0 {
|
||||
if boundMethod.Inputs[0].ReflectType == reflect.TypeFor[Window]() {
|
||||
// Prepend the options.Args with the current window
|
||||
options.Args = append([]interface{}{window}, options.Args...)
|
||||
} else if len(boundMethod.Inputs) > 1 && boundMethod.Inputs[1].ReflectType == reflect.TypeFor[Window]() {
|
||||
if boundMethod.Inputs[0].ReflectType.String() == "application.Window" {
|
||||
// Prepend the options.Args with the current window
|
||||
options.Args = append([]interface{}{window}, options.Args...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user