mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 15:05:08 +00:00
LibGUI: Add context_menu_event to GTreeView
This commit is contained in:
parent
b32e961a84
commit
f26548395e
2 changed files with 15 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ protected:
|
|||
virtual void keydown_event(GKeyEvent&) override;
|
||||
virtual void did_update_selection() override;
|
||||
virtual void did_update_model() override;
|
||||
virtual void context_menu_event(GContextMenuEvent&) override;
|
||||
|
||||
private:
|
||||
GModelIndex index_at_content_position(const Point&, bool& is_toggle) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue