Implement dropdown form selection
This commit is contained in:
parent
5e766f7b7b
commit
ccee813f4a
|
@ -9,6 +9,8 @@
|
||||||
#import "UrlSuggestionView.h"
|
#import "UrlSuggestionView.h"
|
||||||
|
|
||||||
struct browser_window;
|
struct browser_window;
|
||||||
|
struct form_control;
|
||||||
|
|
||||||
@interface BrowserWindowController : NSWindowController<NSTextFieldDelegate, VerticalTabsViewDelegate> {
|
@interface BrowserWindowController : NSWindowController<NSTextFieldDelegate, VerticalTabsViewDelegate> {
|
||||||
id backButton;
|
id backButton;
|
||||||
id forwardButton;
|
id forwardButton;
|
||||||
|
@ -69,6 +71,8 @@ struct browser_window;
|
||||||
-(void)showAll: (NSString*)needle matchCase: (BOOL)matchCase sender: (id)sender;
|
-(void)showAll: (NSString*)needle matchCase: (BOOL)matchCase sender: (id)sender;
|
||||||
-(void)bookmarkPage: (id)sender;
|
-(void)bookmarkPage: (id)sender;
|
||||||
|
|
||||||
|
-(void)showDropdownMenuWithOptions: (NSArray*)options atLocation: (NSPoint)location inTab: (id)tab control: (struct form_control*)control;
|
||||||
|
|
||||||
|
|
||||||
+(id)newTabTarget;
|
+(id)newTabTarget;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -574,6 +574,11 @@ static id newTabTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)showDropdownMenuWithOptions: (NSArray*)options atLocation: (NSPoint)location inTab: (id)tab control: (struct form_control*)control {
|
||||||
|
[[tab plotView] showDropdownMenuWithOptions: options atLocation: location
|
||||||
|
control: control];
|
||||||
|
}
|
||||||
|
|
||||||
+(id)newTabTarget {
|
+(id)newTabTarget {
|
||||||
return newTabTarget;
|
return newTabTarget;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,5 @@
|
||||||
-(void)removeCaret;
|
-(void)removeCaret;
|
||||||
-(void)reload: (id)sender;
|
-(void)reload: (id)sender;
|
||||||
-(void)stopReloading: (id)sender;
|
-(void)stopReloading: (id)sender;
|
||||||
|
-(void)showDropdownMenuWithOptions: (NSArray*)options atLocation: (NSPoint)location control: (struct form_control*)control;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#import "utils/nsoption.h"
|
#import "utils/nsoption.h"
|
||||||
#import "utils/messages.h"
|
#import "utils/messages.h"
|
||||||
#import "netsurf/content_type.h"
|
#import "netsurf/content_type.h"
|
||||||
|
#import "netsurf/form.h"
|
||||||
|
|
||||||
#define colour_red_component( c ) (((c) >> 0) & 0xFF)
|
#define colour_red_component( c ) (((c) >> 0) & 0xFF)
|
||||||
#define colour_green_component( c ) (((c) >> 8) & 0xFF)
|
#define colour_green_component( c ) (((c) >> 8) & 0xFF)
|
||||||
|
@ -796,5 +797,24 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) {
|
||||||
[self openDump: [NSString stringWithCString: fname]];
|
[self openDump: [NSString stringWithCString: fname]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)showDropdownMenuWithOptions: (NSArray*)options atLocation: (NSPoint)location control: (struct form_control*)control {
|
||||||
|
NSMenu *popupMenu = [[NSMenu alloc] initWithTitle: @""];
|
||||||
|
NSMenuItem *opt;
|
||||||
|
for (NSInteger i = 0; i < [options count]; i++) {
|
||||||
|
opt = [popupMenu addItemWithTitle: [options objectAtIndex: i] action:
|
||||||
|
@selector(didPickDropdownOption:) keyEquivalent: @""];
|
||||||
|
[opt setTag: i];
|
||||||
|
[opt setRepresentedObject: [NSValue valueWithPointer: control]];
|
||||||
|
}
|
||||||
|
[NSMenu popUpContextMenu: popupMenu withEvent: nil forView: self];
|
||||||
|
[popupMenu release];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)didPickDropdownOption: (id)sender {
|
||||||
|
NSValue *controlPointer = [sender representedObject];
|
||||||
|
struct form_control *control = (struct form_control*)[controlPointer pointerValue];
|
||||||
|
if (form_select_process_selection(control, [sender tag]) != NSERROR_OK)
|
||||||
|
NSLog(@"Failed to process selection");
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#import "netsurf/types.h"
|
#import "netsurf/types.h"
|
||||||
#import "utils/nsurl.h"
|
#import "utils/nsurl.h"
|
||||||
#import "netsurf/mouse.h"
|
#import "netsurf/mouse.h"
|
||||||
|
#import "netsurf/form.h"
|
||||||
|
|
||||||
struct window_tab {
|
struct window_tab {
|
||||||
BrowserWindowController *window;
|
BrowserWindowController *window;
|
||||||
|
@ -146,6 +147,22 @@ static void gnustep_window_place_caret(struct gui_window *gw, int x, int y, int
|
||||||
[wtab->window placeCaretAtX: x y: y height: height inTab: wtab->tab];
|
[wtab->window placeCaretAtX: x y: y height: height inTab: wtab->tab];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gnustep_window_create_form_select_menu(struct gui_window *gw, struct form_control *control) {
|
||||||
|
struct form_option *opt;
|
||||||
|
struct rect rect;
|
||||||
|
struct window_tab *wtab = (struct window_tab*)gw;
|
||||||
|
if (form_control_bounding_rect(control, &rect) != NSERROR_OK) {
|
||||||
|
NSLog("Failed to get control bounding rect, skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSMutableArray *options = [NSMutableArray array];
|
||||||
|
for(opt = form_select_get_option(control, 0); opt != NULL; opt = opt->next) {
|
||||||
|
[options addObject: [NSString stringWithCString: opt->text]];
|
||||||
|
}
|
||||||
|
[wtab->window showDropdownMenuWithOptions: options atLocation:
|
||||||
|
NSMakePoint(rect.x0, rect.y1) inTab: wtab->tab control: control];
|
||||||
|
}
|
||||||
|
|
||||||
struct gui_window_table gnustep_window_table = {
|
struct gui_window_table gnustep_window_table = {
|
||||||
.create = gnustep_window_create,
|
.create = gnustep_window_create,
|
||||||
.destroy = gnustep_window_destroy,
|
.destroy = gnustep_window_destroy,
|
||||||
|
@ -157,5 +174,6 @@ struct gui_window_table gnustep_window_table = {
|
||||||
.set_title = gnustep_window_set_title,
|
.set_title = gnustep_window_set_title,
|
||||||
.set_url = gnustep_window_set_url,
|
.set_url = gnustep_window_set_url,
|
||||||
.place_caret = gnustep_window_place_caret,
|
.place_caret = gnustep_window_place_caret,
|
||||||
.set_pointer = gnustep_window_set_pointer
|
.set_pointer = gnustep_window_set_pointer,
|
||||||
|
.create_form_select_menu = gnustep_window_create_form_select_menu,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue