mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
LibGUI: Allow dropping drags on AbstractView
You can now drop things on an AbstractView, which will ask its model if the drag is acceptable to drop at the index where it's dropped. If it's accepted by the model, the view will fire the on_drop hook.
This commit is contained in:
@@ -326,4 +326,19 @@ void AbstractView::context_menu_event(ContextMenuEvent& event)
|
||||
on_context_menu_request(index, event);
|
||||
}
|
||||
|
||||
void AbstractView::drop_event(DropEvent& event)
|
||||
{
|
||||
event.accept();
|
||||
|
||||
if (!model())
|
||||
return;
|
||||
|
||||
auto index = index_at_event_position(event.position());
|
||||
if (!index.is_valid())
|
||||
return;
|
||||
|
||||
if (on_drop)
|
||||
on_drop(index, event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user