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:
@@ -79,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)
|
||||
|
||||
ambigiousID := false
|
||||
m.l.Lock()
|
||||
@@ -104,6 +105,13 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter,
|
||||
m.l.Unlock()
|
||||
}()
|
||||
|
||||
// Check if the first bound method parameter is a Window interface
|
||||
if len(boundMethod.Inputs) > 0 {
|
||||
if boundMethod.Inputs[0].ReflectType.String() == "application.Window" {
|
||||
// Prepend the options.Args with the current window
|
||||
options.Args = append([]interface{}{window}, options.Args...)
|
||||
}
|
||||
}
|
||||
result, err := boundMethod.Call(ctx, options.Args)
|
||||
if err != nil {
|
||||
m.callErrorCallback(window, "Error calling method: %s", callID, err)
|
||||
|
||||
Reference in New Issue
Block a user