mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +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
Notes:
sideshowbarker
2024-07-19 06:48:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c3aa249a368
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->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&) {
|
||||
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_action(copy_action());
|
||||
|
@ -772,10 +772,12 @@ void TerminalWidget::emit(const u8* data, size_t size)
|
|||
|
||||
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());
|
||||
else
|
||||
} else {
|
||||
m_context_menu_href = m_hovered_href;
|
||||
m_context_menu_for_hyperlink->popup(event.screen_position());
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalWidget::drop_event(GUI::DropEvent& event)
|
||||
|
|
|
@ -133,6 +133,9 @@ private:
|
|||
String m_hovered_href;
|
||||
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_belling { false };
|
||||
bool m_alt_key_held { false };
|
||||
|
|
Loading…
Reference in a new issue