mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 16:14:57 +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:
parent
8b3864c70a
commit
f0ae353c9e
2 changed files with 17 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue