Mimic GTK port's copy/paste/cut contextual menu logic

This commit is contained in:
anthony 2020-12-07 20:54:57 +00:00
parent 815b39bb16
commit 2bdfe481f2
1 changed files with 29 additions and 20 deletions

View File

@ -325,9 +325,7 @@ static const struct plotter_table gnustep_plotters = {
NSPoint point = [self convertMousePoint: event];
struct browser_window_features cont;
browser_window_get_features(browser, point.x, point.y, &cont);
if (cont.object != NULL) {
id bitmap = (id)content_get_bitmap( cont.object );
const char *cstr = nsurl_access(hlcache_handle_get_url( cont.object ));
@ -346,10 +344,10 @@ static const struct plotter_table gnustep_plotters = {
[[popupMenu addItemWithTitle: @"Copy image"
action: @selector(cmImageCopy:)
keyEquivalent: @""] setRepresentedObject: bitmap];
if (cont.link != NULL) {
[popupMenu addItem: [NSMenuItem separatorItem]];
}
}
if (cont.link != NULL) {
NSString *target = [NSString stringWithUTF8String: nsurl_access(cont.link)];
@ -365,9 +363,8 @@ static const struct plotter_table gnustep_plotters = {
[[popupMenu addItemWithTitle: @"Copy link"
action: @selector(cmLinkCopy:)
keyEquivalent: @""] setRepresentedObject: target];
[popupMenu addItem: [NSMenuItem separatorItem]];
}
if (cont.link == NULL && cont.object == NULL) {
[popupMenu addItemWithTitle: @"Back"
action: @selector(back:) keyEquivalent: @""];
[popupMenu addItemWithTitle: @"Forward"
@ -376,8 +373,20 @@ static const struct plotter_table gnustep_plotters = {
action: @selector(stopReloading:) keyEquivalent: @""];
[popupMenu addItemWithTitle: @"Reload"
action: @selector(reload:) keyEquivalent: @""];
[popupMenu addItem: [NSMenuItem separatorItem]];
char *selection = browser_window_get_selection(browser);
if (selection != NULL) {
if (cont.form_features == CTX_FORM_TEXT) {
[popupMenu addItemWithTitle: @"Cut"
action: @selector(cut:) keyEquivalent: @""];
}
[popupMenu addItemWithTitle: @"Copy"
action: @selector(copy:) keyEquivalent: @""];
free(selection);
}
[popupMenu addItemWithTitle: @"Paste"
action: @selector(paste:) keyEquivalent: @""];
}
[NSMenu popUpContextMenu: popupMenu withEvent: event forView: self];
[popupMenu release];