1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:35:07 +00:00

LibGUI: Add context_menu_event to GTreeView

This commit is contained in:
Tommy Nguyen 2019-12-12 04:48:49 -05:00 committed by Andreas Kling
parent b32e961a84
commit f26548395e
2 changed files with 15 additions and 0 deletions

View file

@ -334,3 +334,17 @@ void GTreeView::keydown_event(GKeyEvent& event)
return;
}
}
void GTreeView::context_menu_event(GContextMenuEvent& event)
{
if (!model())
return;
auto adjusted_position = event.position().translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness());
bool is_toggle;
auto index = index_at_content_position(adjusted_position, is_toggle);
if (index.is_valid()) {
if (on_context_menu_request)
on_context_menu_request(index, event);
}
GAbstractView::context_menu_event(event);
}