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>
238 lines
5.4 KiB
JavaScript
238 lines
5.4 KiB
JavaScript
/*
|
|
_ __ _ __
|
|
| | / /___ _(_) /____
|
|
| | /| / / __ `/ / / ___/
|
|
| |/ |/ / /_/ / / (__ )
|
|
|__/|__/\__,_/_/_/____/
|
|
The electron alternative for Go
|
|
(c) Lea Anthony 2019-present
|
|
*/
|
|
|
|
export function LogPrint(message) {
|
|
window.runtime.LogPrint(message);
|
|
}
|
|
|
|
export function LogTrace(message) {
|
|
window.runtime.LogTrace(message);
|
|
}
|
|
|
|
export function LogDebug(message) {
|
|
window.runtime.LogDebug(message);
|
|
}
|
|
|
|
export function LogInfo(message) {
|
|
window.runtime.LogInfo(message);
|
|
}
|
|
|
|
export function LogWarning(message) {
|
|
window.runtime.LogWarning(message);
|
|
}
|
|
|
|
export function LogError(message) {
|
|
window.runtime.LogError(message);
|
|
}
|
|
|
|
export function LogFatal(message) {
|
|
window.runtime.LogFatal(message);
|
|
}
|
|
|
|
export function EventsOnMultiple(eventName, callback, maxCallbacks) {
|
|
return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks);
|
|
}
|
|
|
|
export function EventsOn(eventName, callback) {
|
|
return EventsOnMultiple(eventName, callback, -1);
|
|
}
|
|
|
|
export function EventsOff(eventName, ...additionalEventNames) {
|
|
return window.runtime.EventsOff(eventName, ...additionalEventNames);
|
|
}
|
|
|
|
export function EventsOnce(eventName, callback) {
|
|
return EventsOnMultiple(eventName, callback, 1);
|
|
}
|
|
|
|
export function EventsEmit(eventName) {
|
|
let args = [eventName].slice.call(arguments);
|
|
return window.runtime.EventsEmit.apply(null, args);
|
|
}
|
|
|
|
export function WindowReload() {
|
|
window.runtime.WindowReload();
|
|
}
|
|
|
|
export function WindowReloadApp() {
|
|
window.runtime.WindowReloadApp();
|
|
}
|
|
|
|
export function WindowSetAlwaysOnTop(b) {
|
|
window.runtime.WindowSetAlwaysOnTop(b);
|
|
}
|
|
|
|
export function WindowSetSystemDefaultTheme() {
|
|
window.runtime.WindowSetSystemDefaultTheme();
|
|
}
|
|
|
|
export function WindowSetLightTheme() {
|
|
window.runtime.WindowSetLightTheme();
|
|
}
|
|
|
|
export function WindowSetDarkTheme() {
|
|
window.runtime.WindowSetDarkTheme();
|
|
}
|
|
|
|
export function WindowCenter() {
|
|
window.runtime.WindowCenter();
|
|
}
|
|
|
|
export function WindowSetTitle(title) {
|
|
window.runtime.WindowSetTitle(title);
|
|
}
|
|
|
|
export function WindowFullscreen() {
|
|
window.runtime.WindowFullscreen();
|
|
}
|
|
|
|
export function WindowUnfullscreen() {
|
|
window.runtime.WindowUnfullscreen();
|
|
}
|
|
|
|
export function WindowIsFullscreen() {
|
|
return window.runtime.WindowIsFullscreen();
|
|
}
|
|
|
|
export function WindowGetSize() {
|
|
return window.runtime.WindowGetSize();
|
|
}
|
|
|
|
export function WindowSetSize(width, height) {
|
|
window.runtime.WindowSetSize(width, height);
|
|
}
|
|
|
|
export function WindowSetMaxSize(width, height) {
|
|
window.runtime.WindowSetMaxSize(width, height);
|
|
}
|
|
|
|
export function WindowSetMinSize(width, height) {
|
|
window.runtime.WindowSetMinSize(width, height);
|
|
}
|
|
|
|
export function WindowSetPosition(x, y) {
|
|
window.runtime.WindowSetPosition(x, y);
|
|
}
|
|
|
|
export function WindowGetPosition() {
|
|
return window.runtime.WindowGetPosition();
|
|
}
|
|
|
|
export function WindowHide() {
|
|
window.runtime.WindowHide();
|
|
}
|
|
|
|
export function WindowShow() {
|
|
window.runtime.WindowShow();
|
|
}
|
|
|
|
export function WindowMaximise() {
|
|
window.runtime.WindowMaximise();
|
|
}
|
|
|
|
export function WindowToggleMaximise() {
|
|
window.runtime.WindowToggleMaximise();
|
|
}
|
|
|
|
export function WindowUnmaximise() {
|
|
window.runtime.WindowUnmaximise();
|
|
}
|
|
|
|
export function WindowIsMaximised() {
|
|
return window.runtime.WindowIsMaximised();
|
|
}
|
|
|
|
export function WindowMinimise() {
|
|
window.runtime.WindowMinimise();
|
|
}
|
|
|
|
export function WindowUnminimise() {
|
|
window.runtime.WindowUnminimise();
|
|
}
|
|
|
|
export function WindowSetBackgroundColour(R, G, B, A) {
|
|
window.runtime.WindowSetBackgroundColour(R, G, B, A);
|
|
}
|
|
|
|
export function ScreenGetAll() {
|
|
return window.runtime.ScreenGetAll();
|
|
}
|
|
|
|
export function WindowIsMinimised() {
|
|
return window.runtime.WindowIsMinimised();
|
|
}
|
|
|
|
export function WindowIsNormal() {
|
|
return window.runtime.WindowIsNormal();
|
|
}
|
|
|
|
export function BrowserOpenURL(url) {
|
|
window.runtime.BrowserOpenURL(url);
|
|
}
|
|
|
|
export function Environment() {
|
|
return window.runtime.Environment();
|
|
}
|
|
|
|
export function Quit() {
|
|
window.runtime.Quit();
|
|
}
|
|
|
|
export function Hide() {
|
|
window.runtime.Hide();
|
|
}
|
|
|
|
export function Show() {
|
|
window.runtime.Show();
|
|
}
|
|
|
|
export function ClipboardGetText() {
|
|
return window.runtime.ClipboardGetText();
|
|
}
|
|
|
|
export function ClipboardSetText(text) {
|
|
return window.runtime.ClipboardSetText(text);
|
|
}
|
|
|
|
/**
|
|
* Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
|
*
|
|
* @export
|
|
* @callback OnFileDropCallback
|
|
* @param {number} x - x coordinate of the drop
|
|
* @param {number} y - y coordinate of the drop
|
|
* @param {string[]} paths - A list of file paths.
|
|
*/
|
|
|
|
/**
|
|
* OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
|
|
*
|
|
* @export
|
|
* @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
|
* @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target)
|
|
*/
|
|
export function OnFileDrop(callback, useDropTarget) {
|
|
return window.runtime.OnFileDrop(callback, useDropTarget);
|
|
}
|
|
|
|
/**
|
|
* OnFileDropOff removes the drag and drop listeners and handlers.
|
|
*/
|
|
export function OnFileDropOff() {
|
|
return window.runtime.OnFileDropOff();
|
|
}
|
|
|
|
export function CanResolveFilePaths() {
|
|
return window.runtime.CanResolveFilePaths();
|
|
}
|
|
|
|
export function ResolveFilePaths(files) {
|
|
return window.runtime.ResolveFilePaths(files);
|
|
} |