mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibVT: Snapshot the URL we're opening a context menu for
Otherwise it may get lost due to a leave event firing in the widget.
This commit is contained in:
parent
31ec4de0ee
commit
c3aa249a36
2 changed files with 9 additions and 4 deletions
|
@ -132,10 +132,10 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<Co
|
||||||
|
|
||||||
m_context_menu_for_hyperlink = GUI::Menu::construct();
|
m_context_menu_for_hyperlink = GUI::Menu::construct();
|
||||||
m_context_menu_for_hyperlink->add_action(GUI::Action::create("Open URL", [this](auto&) {
|
m_context_menu_for_hyperlink->add_action(GUI::Action::create("Open URL", [this](auto&) {
|
||||||
Desktop::Launcher::open(m_hovered_href);
|
Desktop::Launcher::open(m_context_menu_href);
|
||||||
}));
|
}));
|
||||||
m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy URL", [this](auto&) {
|
m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy URL", [this](auto&) {
|
||||||
GUI::Clipboard::the().set_data(m_hovered_href);
|
GUI::Clipboard::the().set_data(m_context_menu_href);
|
||||||
}));
|
}));
|
||||||
m_context_menu_for_hyperlink->add_separator();
|
m_context_menu_for_hyperlink->add_separator();
|
||||||
m_context_menu_for_hyperlink->add_action(copy_action());
|
m_context_menu_for_hyperlink->add_action(copy_action());
|
||||||
|
@ -772,10 +772,12 @@ void TerminalWidget::emit(const u8* data, size_t size)
|
||||||
|
|
||||||
void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
||||||
{
|
{
|
||||||
if (m_hovered_href_id.is_null())
|
if (m_hovered_href_id.is_null()) {
|
||||||
m_context_menu->popup(event.screen_position());
|
m_context_menu->popup(event.screen_position());
|
||||||
else
|
} else {
|
||||||
|
m_context_menu_href = m_hovered_href;
|
||||||
m_context_menu_for_hyperlink->popup(event.screen_position());
|
m_context_menu_for_hyperlink->popup(event.screen_position());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalWidget::drop_event(GUI::DropEvent& event)
|
void TerminalWidget::drop_event(GUI::DropEvent& event)
|
||||||
|
|
|
@ -133,6 +133,9 @@ private:
|
||||||
String m_hovered_href;
|
String m_hovered_href;
|
||||||
String m_hovered_href_id;
|
String m_hovered_href_id;
|
||||||
|
|
||||||
|
// Snapshot of m_hovered_href when opening a context menu for a hyperlink.
|
||||||
|
String m_context_menu_href;
|
||||||
|
|
||||||
bool m_should_beep { false };
|
bool m_should_beep { false };
|
||||||
bool m_belling { false };
|
bool m_belling { false };
|
||||||
bool m_alt_key_held { false };
|
bool m_alt_key_held { false };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue