Skip to content

WebView for Authentication does not accept key commands. #3

Description

@theladyjaye

Sample implementation to forward copy/paste

#import <WebKit/WebKit.h>
@interface DSYWebView : WebView
@end

@implementation DSYWebView

- (void)keyDown:(NSEvent *)theEvent
{
    // no op - kills the beep;
}

- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
{
    NSString * chars = [theEvent characters];
    BOOL status = NO;

    if ([theEvent modifierFlags] & NSCommandKeyMask){

        if ([chars isEqualTo:@"a"]){
            [self selectAll:nil];
            status = YES;
        }

        if ([chars isEqualTo:@"c"]){
            [self copy:nil];
            status = YES;
        }

        if ([chars isEqualTo:@"v"]){
            [self paste:nil];
            status = YES;
        }

        if ([chars isEqualTo:@"x"]){
            [self cut:nil];
            status = YES;
        }
    }
    return status;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions