mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 06:20:48 +08:00

* Feature/1090 native drag and drop for file and folder (#3203) * implement basic dnd for linux * implemented windows * progress changed linux handling and added coordinates to drop * progress fix drop coordinates on windows * progress remove log from windows * progress move js * update js after merge * fix event listener registration * fix segfault on non file drag * remove logs, fix coordinates * minor changes, simplify to drop only * rename EnableWails -> EnableFileDrop * add documentation (PR id missing) * add PR id to changelog * fix remove casting from malloc * fix nil check for OnFileDrop's callback * fix nil check for OnFileDrop skip event when nil * add error message for nil callback in OnFileDrop --------- Co-authored-by: lyimmi <lelvente.zambo@gmail.com> Co-authored-by: Lea Anthony <lea.anthony@gmail.com> * implement native drag and drop for macOS (#3250) * implement native drag and drop for macOS * update docs * add to changelog * update docs (macOS is supported) * Fix windows DragAndDrop options * Fix class unset on dragleave for full frame elements * improve class unset (nested elements and borders case) * Fix runtime drop target detection and CSS class assignment * Edit changelog * Fix drag-and-drop options in references * Update v2/internal/frontend/desktop/darwin/WailsWebView.m * Update v2/internal/frontend/desktop/darwin/WailsWebView.m --------- Co-authored-by: Zámbó, Levente <levente.zambo@gmail.com> Co-authored-by: lyimmi <lelvente.zambo@gmail.com> Co-authored-by: Lea Anthony <lea.anthony@gmail.com> Co-authored-by: Andrey Pshenkin <andrey.pshenkin@gmail.com> Co-authored-by: Pavel Binar <pavel@beamtransfer.io>
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
package dispatcher
|
|
|
|
import (
|
|
"context"
|
|
"github.com/pkg/errors"
|
|
"github.com/wailsapp/wails/v2/internal/binding"
|
|
"github.com/wailsapp/wails/v2/internal/frontend"
|
|
"github.com/wailsapp/wails/v2/internal/logger"
|
|
"github.com/wailsapp/wails/v2/pkg/options"
|
|
)
|
|
|
|
type Dispatcher struct {
|
|
log *logger.Logger
|
|
bindings *binding.Bindings
|
|
events frontend.Events
|
|
bindingsDB *binding.DB
|
|
ctx context.Context
|
|
errfmt options.ErrorFormatter
|
|
}
|
|
|
|
func NewDispatcher(ctx context.Context, log *logger.Logger, bindings *binding.Bindings, events frontend.Events, errfmt options.ErrorFormatter) *Dispatcher {
|
|
return &Dispatcher{
|
|
log: log,
|
|
bindings: bindings,
|
|
events: events,
|
|
bindingsDB: bindings.DB(),
|
|
ctx: ctx,
|
|
errfmt: errfmt,
|
|
}
|
|
}
|
|
|
|
func (d *Dispatcher) ProcessMessage(message string, sender frontend.Frontend) (string, error) {
|
|
if message == "" {
|
|
return "", errors.New("No message to process")
|
|
}
|
|
switch message[0] {
|
|
case 'L':
|
|
return d.processLogMessage(message)
|
|
case 'E':
|
|
return d.processEventMessage(message, sender)
|
|
case 'C':
|
|
return d.processCallMessage(message, sender)
|
|
case 'c':
|
|
return d.processSecureCallMessage(message, sender)
|
|
case 'W':
|
|
return d.processWindowMessage(message, sender)
|
|
case 'B':
|
|
return d.processBrowserMessage(message, sender)
|
|
case 'D':
|
|
return d.processDragAndDropMessage(message)
|
|
case 'Q':
|
|
sender.Quit()
|
|
return "", nil
|
|
case 'S':
|
|
sender.Show()
|
|
return "", nil
|
|
case 'H':
|
|
sender.Hide()
|
|
return "", nil
|
|
default:
|
|
return "", errors.New("Unknown message from front end: " + message)
|
|
}
|
|
}
|