mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibVT: Add a context menu to TerminalWidget
Starting with only the copy and paste actions. But I'm sure we can come up with some more things to put here. :^)
This commit is contained in:
parent
dbf8d6bc1e
commit
dabdd484f7
Notes:
sideshowbarker
2024-07-19 11:08:02 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/dabdd484f79
2 changed files with 14 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GClipboard.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
|
@ -654,3 +655,13 @@ void TerminalWidget::beep()
|
|||
};
|
||||
force_repaint();
|
||||
}
|
||||
|
||||
void TerminalWidget::context_menu_event(GContextMenuEvent& event)
|
||||
{
|
||||
if (!m_context_menu) {
|
||||
m_context_menu = make<GMenu>();
|
||||
m_context_menu->add_action(copy_action());
|
||||
m_context_menu->add_action(paste_action());
|
||||
}
|
||||
m_context_menu->popup(event.screen_position());
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
virtual void doubleclick_event(GMouseEvent&) override;
|
||||
virtual void focusin_event(CEvent&) override;
|
||||
virtual void focusout_event(CEvent&) override;
|
||||
virtual void context_menu_event(GContextMenuEvent&) override;
|
||||
|
||||
// ^TerminalClient
|
||||
virtual void beep() override;
|
||||
|
@ -128,5 +129,7 @@ private:
|
|||
RefPtr<GAction> m_copy_action;
|
||||
RefPtr<GAction> m_paste_action;
|
||||
|
||||
OwnPtr<GMenu> m_context_menu;
|
||||
|
||||
CElapsedTimer m_triple_click_timer;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue