ExternalDragDrop

class omni.kit.window.drop_support.drop_support.ExternalDragDrop(window_name: str, drag_drop_fn: callable)

Bases: object

A class to handle external drag and drop events for a specified window.

The class subscribes to drag and drop events on the application’s main window and invokes a callback function when an event is detected over the specified window area. It also provides utility functions to check mouse coordinates and expand drag and drop payloads that contain directories.

Parameters
  • window_name (str) – The name of the window to monitor for drag/drop events.

  • drag_drop_fn (callable) – The callback function to invoke on a drag/drop event.

Methods

__init__(window_name, drag_drop_fn)

Initializes the ExternalDragDrop with a window name and a drag and drop function.

destroy()

Cleans up the resources and subscriptions held by the class instance.

expand_payload(payload)

Expands payload to include all files within any directories.

get_current_mouse_coords()

Retrieves the current mouse coordinates scaled by the DPI scale.

is_window_hovered(pos_x, pos_y, window_name)

Checks if the mouse is hovering over the specified window.

__init__(window_name: str, drag_drop_fn: callable)

Initializes the ExternalDragDrop with a window name and a drag and drop function.

destroy()

Cleans up the resources and subscriptions held by the class instance.

expand_payload(payload)

Expands payload to include all files within any directories.

Parameters

payload (list of str) – A list of file paths to expand.

Returns

A new list of file paths including files within directories in the payload.

Return type

list of str

get_current_mouse_coords()

Retrieves the current mouse coordinates scaled by the DPI scale.

is_window_hovered(pos_x, pos_y, window_name)

Checks if the mouse is hovering over the specified window.

Parameters
  • pos_x (float) – The x-coordinate of the mouse position.

  • pos_y (float) – The y-coordinate of the mouse position.

  • window_name (str) – The name of the window to check against.

Returns

True if the mouse is hovering over the window, False otherwise.

Return type

bool