Make the dropdown widget's file drop a callback and keep stray file drops from navigating the browser away (#4553)

* Make the dropdown widget's file drop a callback and keep stray file drops from navigating the browser away

* Look up the dropped file's widget before reading the file
This commit is contained in:
Keavon Chambers
2026-09-19 16:01:58 -07:00
committed by GitHub
parent 97d8452a1d
commit 23e6b0f11d
10 changed files with 100 additions and 15 deletions
+9 -2
View File
@@ -22,7 +22,7 @@ mod editor_commands {
use editor::messages::portfolio::document::utility_types::network_interface::ImportOrExport;
use editor::messages::portfolio::utility_types::PanelGroupId;
use editor::messages::prelude::*;
use editor::messages::tool::tool_messages::tool_prelude::WidgetId;
use editor::messages::tool::tool_messages::tool_prelude::{DroppedFile, WidgetId};
use graph_craft::document::NodeId;
use graphene_std::raster::color::Color;
use graphene_std::vector::style::FillChoice;
@@ -176,6 +176,13 @@ mod editor_commands {
LayoutMessage::WidgetValueDragDrop { layout_target, widget_id }.into()
}
/// Hand a file dropped on a UI widget to the widget's file drop callback
fn widget_value_file_drop(layout_target: LayoutTarget, widget_id: u64, name: String, mime_type: String, data: Vec<u8>) -> Message {
let widget_id = WidgetId(widget_id);
let file = DroppedFile { name, mime_type, data };
LayoutMessage::WidgetValueFileDrop { layout_target, widget_id, file }.into()
}
/// Closes out the current transaction (drag-end / text-commit end), so emits during a slider drag collapse into one history step instead of N
fn end_transaction() -> Message {
DocumentMessage::EndTransaction.into()
@@ -597,7 +604,7 @@ mod editor_commands {
ClipboardMessage::ReadSelection { content, cut }.into()
}
/// A file headed for a known action, either picked in the dialog that `TriggerBrowse` opened or dropped onto a widget that takes files
/// A file headed for a known action, picked in the dialog that `TriggerBrowse` opened
fn ingest_picked(name: String, mime_type: String, data: Vec<u8>, action: IngestAction) -> Message {
IngestMessage::Ingest {
data,