[TxMt Plugins] sendAction Question

Kirt Fitzpatrick kirt.fitzpatrick at gmail.com
Sat Mar 31 22:26:19 UTC 2007


I figured it out.  The firstResponder had what I needed after all.  I could
have sworn that I had tried this before.  Anyway, it works now.  Thanks for
your help and patience.

kirt


@implementation ViWindow

- (void)sendEvent:(NSEvent *)theEvent
{
    if ( [theEvent type] == NSKeyDown ) {
        if ( [[theEvent charactersIgnoringModifiers] characterAtIndex: 0] ==
'h' ) {
            NSLog( @"we are trying to move left." );
            // This is the way to call the virtual methods.
            [[self firstResponder] performSelector: @selector(moveLeft:)
withObject: self];
        } else {
            [super sendEvent:theEvent];
        }
    } else {
        [super sendEvent:theEvent];
    }
}

@end









On 3/31/07, Kirt Fitzpatrick <kirt.fitzpatrick at gmail.com> wrote:
>
> I have created a new project that distills out only the minimum code
> needed for this plugin to send a message to the active window.  You can
> download it here <http://fowpas.net/ViMate.zip> (http://fowpas.net/ViMate.zip).
> It of course does not work but I am hoping that someone may be able to tell
> me why.  Here is the most relevant code.
>
>
>
> @implementation ViPlugin
> - (id)initWithPlugInController:(id <TMPlugInController>)aController
> {
>     NSLog( @"we have lift off!" );
>     [ViWindow poseAsClass:[NSWindow class]];
>
>     return [super init];
> }
> @end
>
>
>
>
>
> @implementation ViWindow
> - (void)sendEvent:(NSEvent *)theEvent
> {
>     if ( [theEvent type] == NSKeyDown ) {
>         if ( [[theEvent charactersIgnoringModifiers] characterAtIndex: 0]
> == 'h' ) {
>             NSLog( @"we are trying to move left." );
>             [[NSApplication sharedApplication] sendAction:
> @selector(moveLeft:) to: nil from: self];
>         } else {
>             [super sendEvent:theEvent];
>         }
>     } else {
>         [super sendEvent:theEvent];
>     }
> }
> @end
>
>
>
>
> thanks
> kirt
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate-plugins/attachments/20070331/1cd0f11a/attachment.html>


More information about the textmate-plugins mailing list