mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Ladybird/AppKit: Implement pasting content from the clipboard
This commit is contained in:
parent
0069390e1c
commit
ed24d8f2b5
Notes:
sideshowbarker
2024-07-17 07:20:57 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/ed24d8f2b5 Pull-request: https://github.com/SerenityOS/serenity/pull/23707
1 changed files with 12 additions and 0 deletions
|
@ -873,6 +873,15 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
|
|||
copy_data_to_clipboard(m_web_view_bridge->selected_text(), NSPasteboardTypeString);
|
||||
}
|
||||
|
||||
- (void)paste:(id)sender
|
||||
{
|
||||
auto* paste_board = [NSPasteboard generalPasteboard];
|
||||
|
||||
if (auto* contents = [paste_board stringForType:NSPasteboardTypeString]) {
|
||||
m_web_view_bridge->paste(Ladybird::ns_string_to_string(contents));
|
||||
}
|
||||
}
|
||||
|
||||
- (void)selectAll:(id)sender
|
||||
{
|
||||
m_web_view_bridge->select_all();
|
||||
|
@ -1003,6 +1012,9 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
|
|||
[_page_context_menu addItem:[[NSMenuItem alloc] initWithTitle:@"Copy"
|
||||
action:@selector(copy:)
|
||||
keyEquivalent:@""]];
|
||||
[_page_context_menu addItem:[[NSMenuItem alloc] initWithTitle:@"Paste"
|
||||
action:@selector(paste:)
|
||||
keyEquivalent:@""]];
|
||||
[_page_context_menu addItem:[[NSMenuItem alloc] initWithTitle:@"Select All"
|
||||
action:@selector(selectAll:)
|
||||
keyEquivalent:@""]];
|
||||
|
|
Loading…
Reference in a new issue