Skip navigation.
 
mlHow to create an NSEvent for Option-E?
FROM : Glen Simmons
DATE : Tue Aug 29 23:03:32 2006

I'd like to create and send an event for Option-E. I tried this code, 
using the same values the system-generated event has:

    NSEvent* fakeEvent = [NSEvent keyEventWithType:NSKeyDown
                                          location:NSZeroPoint
                                      modifierFlags:0x80120
                                          timestamp:0
                                      windowNumber:[[NSApp 
mainWindow] windowNumber]
                                            context:nil
                                        characters:@""
                        charactersIgnoringModifiers:@"e"
                                          isARepeat:NO
                                            keyCode:14];
    [NSApp postEvent:fakeEvent atStart:NO];

This throws an exception: *** -[NSCFString characterAtIndex:]: Range 
or index out of bounds

Why? What's wrong with this code? How can I send an event for Option-E?

Thanks,
Glen Simmons

Related mailsAuthorDate
mlHow to create an NSEvent for Option-E? Glen Simmons Aug 29, 23:03
mlRe: How to create an NSEvent for Option-E? Uli Kusterer Aug 30, 19:40
mlRe: How to create an NSEvent for Option-E? Glen Simmons Aug 30, 19:51
mlRe: How to create an NSEvent for Option-E? Aki Inoue Aug 30, 23:09