sendAction Question

View: New views
15 Messages — Rating Filter:   Alert me  

sendAction Question

by Kirt Fitzpatrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to call the moveLeft method on the editor window and I don't seem to be having any luck.  I am a bit of a n00b to Objective C so I assume that I must be missing something.  This is what I came up with.  Am I doing something wrong?

SEL methodSelector = sel_registerName( "moveLeft" );  
[[NSApplication sharedApplication] sendAction:methodSelector to:nil from:self];

kirt


_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Rob Rix :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, you are doing something wrong.

I don't know if -sendAction:to:from: is the best way to accomplish  
your goal here, but you definitely don't want to be doing  
sel_registerName here. Instead you want @selector as follows:

[[NSApplication sharedApplication] sendAction: @selector(moveLeft:)  
to: nil from: self];

Notice the colon after moveLeft. Action methods always take a  
'sender' argument, which is what you're supplying in the 'from:' part  
of sendAction:to:from:. See file:///Developer/ADC%20Reference%
20Library/documentation/Cocoa/Reference/ApplicationKit/Classes/
NSresponder_Class/index.html for more information.

Rob

On 17-Mar-07, at 5:52 PM, Kirt Fitzpatrick wrote:

> I am trying to call the moveLeft method on the editor window and I  
> don't seem to be having any luck.  I am a bit of a n00b to  
> Objective C so I assume that I must be missing something.  This is  
> what I came up with.  Am I doing something wrong?
>
> SEL methodSelector = sel_registerName( "moveLeft" );
> [[NSApplication sharedApplication] sendAction:methodSelector to:nil  
> from:self];
>
> kirt
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Todd Ditchendorf-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kirt, I've done quite a bit of communication from a tm plugin to the  
TM front most window[1][2][3]... I think you should probably try  
something like this:

[[[NSApplication sharedApplication] mainWindow] moveLeft:self]


Note that +[NSApplication sharedApplication] returns an NSApplication  
instance, not a window. An NSApplication handles much of the  
application's lifecycle. A window is represented by NSWindow. The  
frontmost TM editing window can always be fetched by calling -
[NSApplication mainWindow] on the TM application instance from your  
plugin, as shown above

If I were Allan, I would probably admonish you not to do anything too  
crazy to the frontmost TM window from your plugin, as it might  
surprise users. But then again, as I mentioned, I've probably done  
more peeking under TM's skirt with my plugins than anyone else  
has...  So far Allan hasn't complained ;-]


[1] http://ditchnet.ort/texmlmate
[2] http://ditchnet.ort/texslmate
[3] http://ditchnet.ort/blogmate


Todd Ditchendorf

Scandalous Software - Mac XML Developer Tools
http://scan.dalo.us



On Mar 17, 2007, at 2:52 PM, Kirt Fitzpatrick wrote:

> I am trying to call the moveLeft method on the editor window and I  
> don't seem to be having any luck.  I am a bit of a n00b to  
> Objective C so I assume that I must be missing something.  This is  
> what I came up with.  Am I doing something wrong?
>
> SEL methodSelector = sel_registerName( "moveLeft" );
> [[NSApplication sharedApplication] sendAction:methodSelector to:nil  
> from:self];
>
> kirt
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Todd Ditchendorf-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

oh... and btw, I don't think the line below is going to work  
anyhow... first of all, I think I gave you some bumb advice... I'd  
never heard of moveLeft: before... I just looked it up, and it looks  
like it's something that an NSTextView might implement, not an NSWindow.

More importantly, Allan has developed his own alternative to  
NSTextView in TM, called OakTextView, and I would not be surprised if  
it doesn't implement that method anyhow, so this might be a dead end.

Todd Ditchendorf

Scandalous Software - Mac XML Developer Tools
http://scan.dalo.us



On Mar 17, 2007, at 3:39 PM, Todd Ditchendorf wrote:

> Kirt, I've done quite a bit of communication from a tm plugin to  
> the TM front most window[1][2][3]... I think you should probably  
> try something like this:
>
> [[[NSApplication sharedApplication] mainWindow] moveLeft:self]
>
>
> Note that +[NSApplication sharedApplication] returns an  
> NSApplication instance, not a window. An NSApplication handles much  
> of the application's lifecycle. A window is represented by  
> NSWindow. The frontmost TM editing window can always be fetched by  
> calling -[NSApplication mainWindow] on the TM application instance  
> from your plugin, as shown above
>
> If I were Allan, I would probably admonish you not to do anything  
> too crazy to the frontmost TM window from your plugin, as it might  
> surprise users. But then again, as I mentioned, I've probably done  
> more peeking under TM's skirt with my plugins than anyone else  
> has...  So far Allan hasn't complained ;-]
>
>
> [1] http://ditchnet.ort/texmlmate
> [2] http://ditchnet.ort/texslmate
> [3] http://ditchnet.ort/blogmate
>
>
> Todd Ditchendorf
>
> Scandalous Software - Mac XML Developer Tools
> http://scan.dalo.us
>
>
>
> On Mar 17, 2007, at 2:52 PM, Kirt Fitzpatrick wrote:
>
>> I am trying to call the moveLeft method on the editor window and I  
>> don't seem to be having any luck.  I am a bit of a n00b to  
>> Objective C so I assume that I must be missing something.  This is  
>> what I came up with.  Am I doing something wrong?
>>
>> SEL methodSelector = sel_registerName( "moveLeft" );
>> [[NSApplication sharedApplication] sendAction:methodSelector  
>> to:nil from:self];
>>
>> kirt
>>
>> _______________________________________________
>> textmate-plugins mailing list
>> textmate-plugins@...
>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Rob Rix :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Actually it's an NSResponder method, and taking a glance at  
TextMate.app/Contents/Resources/KeyBindings.dict shows that a number  
of NSResponder methods are implemented by TextMate.

It's worth a shot.

Rob

On 17-Mar-07, at 6:46 PM, Todd Ditchendorf wrote:

> oh... and btw, I don't think the line below is going to work  
> anyhow... first of all, I think I gave you some bumb advice... I'd  
> never heard of moveLeft: before... I just looked it up, and it  
> looks like it's something that an NSTextView might implement, not  
> an NSWindow.
>
> More importantly, Allan has developed his own alternative to  
> NSTextView in TM, called OakTextView, and I would not be surprised  
> if it doesn't implement that method anyhow, so this might be a dead  
> end.
>
> Todd Ditchendorf
>
> Scandalous Software - Mac XML Developer Tools
> http://scan.dalo.us
>
>
>
> On Mar 17, 2007, at 3:39 PM, Todd Ditchendorf wrote:
>
>> Kirt, I've done quite a bit of communication from a tm plugin to  
>> the TM front most window[1][2][3]... I think you should probably  
>> try something like this:
>>
>> [[[NSApplication sharedApplication] mainWindow] moveLeft:self]
>>
>>
>> Note that +[NSApplication sharedApplication] returns an  
>> NSApplication instance, not a window. An NSApplication handles  
>> much of the application's lifecycle. A window is represented by  
>> NSWindow. The frontmost TM editing window can always be fetched by  
>> calling -[NSApplication mainWindow] on the TM application instance  
>> from your plugin, as shown above
>>
>> If I were Allan, I would probably admonish you not to do anything  
>> too crazy to the frontmost TM window from your plugin, as it might  
>> surprise users. But then again, as I mentioned, I've probably done  
>> more peeking under TM's skirt with my plugins than anyone else  
>> has...  So far Allan hasn't complained ;-]
>>
>>
>> [1] http://ditchnet.ort/texmlmate
>> [2] http://ditchnet.ort/texslmate
>> [3] http://ditchnet.ort/blogmate
>>
>>
>> Todd Ditchendorf
>>
>> Scandalous Software - Mac XML Developer Tools
>> http://scan.dalo.us
>>
>>
>>
>> On Mar 17, 2007, at 2:52 PM, Kirt Fitzpatrick wrote:
>>
>>> I am trying to call the moveLeft method on the editor window and  
>>> I don't seem to be having any luck.  I am a bit of a n00b to  
>>> Objective C so I assume that I must be missing something.  This  
>>> is what I came up with.  Am I doing something wrong?
>>>
>>> SEL methodSelector = sel_registerName( "moveLeft" );
>>> [[NSApplication sharedApplication] sendAction:methodSelector  
>>> to:nil from:self];
>>>
>>> kirt
>>>
>>> _______________________________________________
>>> textmate-plugins mailing list
>>> textmate-plugins@...
>>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>>
>> _______________________________________________
>> textmate-plugins mailing list
>> textmate-plugins@...
>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Todd Ditchendorf-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Actually it's an NSResponder method,

yes, but if you're trying to move the text selection caret, the impl  
you actually want to call will be in something like NSTextView.

> It's worth a shot.

agreed. but still... I've peeked into the OakTextView.h header file  
using class-dump[1], and I don't see moveLeft: listed there. I really  
don't think this will work.

[1] http://www.codethecode.com/Projects/class-dump/

Todd Ditchendorf

Scandalous Software - Mac XML Developer Tools
http://scan.dalo.us



On Mar 17, 2007, at 3:51 PM, Rob Rix wrote:

> Actually it's an NSResponder method, and taking a glance at  
> TextMate.app/Contents/Resources/KeyBindings.dict shows that a  
> number of NSResponder methods are implemented by TextMate.
>
> It's worth a shot.
>
> Rob
>
> On 17-Mar-07, at 6:46 PM, Todd Ditchendorf wrote:
>
>> oh... and btw, I don't think the line below is going to work  
>> anyhow... first of all, I think I gave you some bumb advice... I'd  
>> never heard of moveLeft: before... I just looked it up, and it  
>> looks like it's something that an NSTextView might implement, not  
>> an NSWindow.
>>
>> More importantly, Allan has developed his own alternative to  
>> NSTextView in TM, called OakTextView, and I would not be surprised  
>> if it doesn't implement that method anyhow, so this might be a  
>> dead end.
>>
>> Todd Ditchendorf
>>
>> Scandalous Software - Mac XML Developer Tools
>> http://scan.dalo.us
>>
>>
>>
>> On Mar 17, 2007, at 3:39 PM, Todd Ditchendorf wrote:
>>
>>> Kirt, I've done quite a bit of communication from a tm plugin to  
>>> the TM front most window[1][2][3]... I think you should probably  
>>> try something like this:
>>>
>>> [[[NSApplication sharedApplication] mainWindow] moveLeft:self]
>>>
>>>
>>> Note that +[NSApplication sharedApplication] returns an  
>>> NSApplication instance, not a window. An NSApplication handles  
>>> much of the application's lifecycle. A window is represented by  
>>> NSWindow. The frontmost TM editing window can always be fetched  
>>> by calling -[NSApplication mainWindow] on the TM application  
>>> instance from your plugin, as shown above
>>>
>>> If I were Allan, I would probably admonish you not to do anything  
>>> too crazy to the frontmost TM window from your plugin, as it  
>>> might surprise users. But then again, as I mentioned, I've  
>>> probably done more peeking under TM's skirt with my plugins than  
>>> anyone else has...  So far Allan hasn't complained ;-]
>>>
>>>
>>> [1] http://ditchnet.ort/texmlmate
>>> [2] http://ditchnet.ort/texslmate
>>> [3] http://ditchnet.ort/blogmate
>>>
>>>
>>> Todd Ditchendorf
>>>
>>> Scandalous Software - Mac XML Developer Tools
>>> http://scan.dalo.us
>>>
>>>
>>>
>>> On Mar 17, 2007, at 2:52 PM, Kirt Fitzpatrick wrote:
>>>
>>>> I am trying to call the moveLeft method on the editor window and  
>>>> I don't seem to be having any luck.  I am a bit of a n00b to  
>>>> Objective C so I assume that I must be missing something.  This  
>>>> is what I came up with.  Am I doing something wrong?
>>>>
>>>> SEL methodSelector = sel_registerName( "moveLeft" );
>>>> [[NSApplication sharedApplication] sendAction:methodSelector  
>>>> to:nil from:self];
>>>>
>>>> kirt
>>>>
>>>> _______________________________________________
>>>> textmate-plugins mailing list
>>>> textmate-plugins@...
>>>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>>>
>>> _______________________________________________
>>> textmate-plugins mailing list
>>> textmate-plugins@...
>>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>>
>> _______________________________________________
>> textmate-plugins mailing list
>> textmate-plugins@...
>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Kirt Fitzpatrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It Todd appears is right.  Which is what I was afraid of.  Now I really need to work blind (without documentation).

kirt

On 3/17/07, Todd Ditchendorf <itod@...> wrote:
> Actually it's an NSResponder method,

yes, but if you're trying to move the text selection caret, the impl
you actually want to call will be in something like NSTextView.

> It's worth a shot.

agreed. but still... I've peeked into the OakTextView.h header file
using class-dump[1], and I don't see moveLeft: listed there. I really
don't think this will work.

[1] http://www.codethecode.com/Projects/class-dump/

Todd Ditchendorf

Scandalous Software - Mac XML Developer Tools
http://scan.dalo.us



On Mar 17, 2007, at 3:51 PM, Rob Rix wrote:

> Actually it's an NSResponder method, and taking a glance at
> TextMate.app/Contents/Resources/KeyBindings.dict shows that a
> number of NSResponder methods are implemented by TextMate.
>
> It's worth a shot.
>
> Rob
>
> On 17-Mar-07, at 6:46 PM, Todd Ditchendorf wrote:
>
>> oh... and btw, I don't think the line below is going to work
>> anyhow... first of all, I think I gave you some bumb advice... I'd
>> never heard of moveLeft: before... I just looked it up, and it
>> looks like it's something that an NSTextView might implement, not
>> an NSWindow.
>>
>> More importantly, Allan has developed his own alternative to
>> NSTextView in TM, called OakTextView, and I would not be surprised
>> if it doesn't implement that method anyhow, so this might be a
>> dead end.
>>
>> Todd Ditchendorf
>>
>> Scandalous Software - Mac XML Developer Tools
>> http://scan.dalo.us
>>
>>
>>
>> On Mar 17, 2007, at 3:39 PM, Todd Ditchendorf wrote:
>>
>>> Kirt, I've done quite a bit of communication from a tm plugin to
>>> the TM front most window[1][2][3]... I think you should probably
>>> try something like this:
>>>
>>> [[[NSApplication sharedApplication] mainWindow] moveLeft:self]
>>>

>>>
>>> Note that +[NSApplication sharedApplication] returns an
>>> NSApplication instance, not a window. An NSApplication handles
>>> much of the application's lifecycle. A window is represented by
>>> NSWindow. The frontmost TM editing window can always be fetched
>>> by calling -[NSApplication mainWindow] on the TM application
>>> instance from your plugin, as shown above
>>>
>>> If I were Allan, I would probably admonish you not to do anything
>>> too crazy to the frontmost TM window from your plugin, as it
>>> might surprise users. But then again, as I mentioned, I've
>>> probably done more peeking under TM's skirt with my plugins than
>>> anyone else has...  So far Allan hasn't complained ;-]
>>>
>>>
>>> [1] http://ditchnet.ort/texmlmate
>>> [2] http://ditchnet.ort/texslmate
>>> [3] http://ditchnet.ort/blogmate
>>>

>>>
>>> Todd Ditchendorf
>>>
>>> Scandalous Software - Mac XML Developer Tools
>>> http://scan.dalo.us
>>>
>>>
>>>
>>> On Mar 17, 2007, at 2:52 PM, Kirt Fitzpatrick wrote:
>>>
>>>> I am trying to call the moveLeft method on the editor window and
>>>> I don't seem to be having any luck.  I am a bit of a n00b to
>>>> Objective C so I assume that I must be missing something.  This
>>>> is what I came up with.  Am I doing something wrong?
>>>>
>>>> SEL methodSelector = sel_registerName( "moveLeft" );
>>>> [[NSApplication sharedApplication] sendAction:methodSelector
>>>> to:nil from:self];
>>>>
>>>> kirt
>>>>
>>>> _______________________________________________
>>>> textmate-plugins mailing list
>>>> textmate-plugins@...
>>>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>>>
>>> _______________________________________________
>>> textmate-plugins mailing list
>>> textmate-plugins@...
>>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>>
>> _______________________________________________
>> textmate-plugins mailing list
>> textmate-plugins@...
>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins


_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Todd Ditchendorf-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

really we're going about this all wrong... TM has lots of great  
documentation and a wonderful dev community. You should describe here  
what effect it is you are trying to achieve. there's bound to be a  
way to do it... and possibly even thru published/documented api.

Todd Ditchendorf

Scandalous Software - Mac XML Developer Tools
http://scan.dalo.us



On Mar 17, 2007, at 4:03 PM, Kirt Fitzpatrick wrote:

> It Todd appears is right.  Which is what I was afraid of.  Now I  
> really need to work blind (without documentation).
>
> kirt
>
> On 3/17/07, Todd Ditchendorf <itod@...> wrote:> Actually it's  
> an NSResponder method,
>
> yes, but if you're trying to move the text selection caret, the impl
> you actually want to call will be in something like NSTextView.
>
> > It's worth a shot.
>
> agreed. but still... I've peeked into the OakTextView.h header file
> using class-dump[1], and I don't see moveLeft: listed there. I really
> don't think this will work.
>
> [1] http://www.codethecode.com/Projects/class-dump/
>
> Todd Ditchendorf
>
> Scandalous Software - Mac XML Developer Tools
> http://scan.dalo.us
>
>
>
> On Mar 17, 2007, at 3:51 PM, Rob Rix wrote:
>
> > Actually it's an NSResponder method, and taking a glance at
> > TextMate.app/Contents/Resources/KeyBindings.dict shows that a
> > number of NSResponder methods are implemented by TextMate.
> >
> > It's worth a shot.
> >
> > Rob
> >
> > On 17-Mar-07, at 6:46 PM, Todd Ditchendorf wrote:
> >
> >> oh... and btw, I don't think the line below is going to work
> >> anyhow... first of all, I think I gave you some bumb advice... I'd
> >> never heard of moveLeft: before... I just looked it up, and it
> >> looks like it's something that an NSTextView might implement, not
> >> an NSWindow.
> >>
> >> More importantly, Allan has developed his own alternative to
> >> NSTextView in TM, called OakTextView, and I would not be surprised
> >> if it doesn't implement that method anyhow, so this might be a
> >> dead end.
> >>
> >> Todd Ditchendorf
> >>
> >> Scandalous Software - Mac XML Developer Tools
> >> http://scan.dalo.us
> >>
> >>
> >>
> >> On Mar 17, 2007, at 3:39 PM, Todd Ditchendorf wrote:
> >>
> >>> Kirt, I've done quite a bit of communication from a tm plugin to
> >>> the TM front most window[1][2][3]... I think you should probably
> >>> try something like this:
> >>>
> >>> [[[NSApplication sharedApplication] mainWindow] moveLeft:self]
> >>>
> >>>
> >>> Note that +[NSApplication sharedApplication] returns an
> >>> NSApplication instance, not a window. An NSApplication handles
> >>> much of the application's lifecycle. A window is represented by
> >>> NSWindow. The frontmost TM editing window can always be fetched
> >>> by calling -[NSApplication mainWindow] on the TM application
> >>> instance from your plugin, as shown above
> >>>
> >>> If I were Allan, I would probably admonish you not to do anything
> >>> too crazy to the frontmost TM window from your plugin, as it
> >>> might surprise users. But then again, as I mentioned, I've
> >>> probably done more peeking under TM's skirt with my plugins than
> >>> anyone else has...  So far Allan hasn't complained ;-]
> >>>
> >>>
> >>> [1] http://ditchnet.ort/texmlmate
> >>> [2] http://ditchnet.ort/texslmate
> >>> [3] http://ditchnet.ort/blogmate
> >>>
> >>>
> >>> Todd Ditchendorf
> >>>
> >>> Scandalous Software - Mac XML Developer Tools
> >>> http://scan.dalo.us
> >>>
> >>>
> >>>
> >>> On Mar 17, 2007, at 2:52 PM, Kirt Fitzpatrick wrote:
> >>>
> >>>> I am trying to call the moveLeft method on the editor window and
> >>>> I don't seem to be having any luck.  I am a bit of a n00b to
> >>>> Objective C so I assume that I must be missing something.  This
> >>>> is what I came up with.  Am I doing something wrong?
> >>>>
> >>>> SEL methodSelector = sel_registerName( "moveLeft" );
> >>>> [[NSApplication sharedApplication] sendAction:methodSelector
> >>>> to:nil from:self];
> >>>>
> >>>> kirt
> >>>>
> >>>> _______________________________________________
> >>>> textmate-plugins mailing list
> >>>> textmate-plugins@...
> >>>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
> >>>
> >>> _______________________________________________
> >>> textmate-plugins mailing list
> >>> textmate-plugins@...
> >>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
> >>
> >> _______________________________________________
> >> textmate-plugins mailing list
> >> textmate-plugins@...
> >> http://lists.macromates.com/mailman/listinfo/textmate-plugins
> >
> > _______________________________________________
> > textmate-plugins mailing list
> > textmate-plugins@...
> > http://lists.macromates.com/mailman/listinfo/textmate-plugins
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Kirt Fitzpatrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm writing a Vi plugin, Currently I must create a list of events and send them to NSWindow.  However, this does not work for alot of actions that I need.  I need to be able to execute all of the movement commands and selection commands.  Having access to the undo stack would be great too.

kirt


On 3/17/07, Todd Ditchendorf <itod@...> wrote:
really we're going about this all wrong... TM has lots of great
documentation and a wonderful dev community. You should describe here
what effect it is you are trying to achieve. there's bound to be a
way to do it... and possibly even thru published/documented api.

Todd Ditchendorf

Scandalous Software - Mac XML Developer Tools
http://scan.dalo.us



On Mar 17, 2007, at 4:03 PM, Kirt Fitzpatrick wrote:

> It Todd appears is right.  Which is what I was afraid of.  Now I
> really need to work blind (without documentation).
>
> kirt
>
> On 3/17/07, Todd Ditchendorf <itod@...> wrote:> Actually it's
> an NSResponder method,
>
> yes, but if you're trying to move the text selection caret, the impl
> you actually want to call will be in something like NSTextView.
>
> > It's worth a shot.
>
> agreed. but still... I've peeked into the OakTextView.h header file
> using class-dump[1], and I don't see moveLeft: listed there. I really
> don't think this will work.
>
> [1] http://www.codethecode.com/Projects/class-dump/
>
> Todd Ditchendorf
>
> Scandalous Software - Mac XML Developer Tools
> http://scan.dalo.us
>
>
>
> On Mar 17, 2007, at 3:51 PM, Rob Rix wrote:
>
> > Actually it's an NSResponder method, and taking a glance at
> > TextMate.app/Contents/Resources/KeyBindings.dict shows that a
> > number of NSResponder methods are implemented by TextMate.

> >
> > It's worth a shot.
> >
> > Rob
> >
> > On 17-Mar-07, at 6:46 PM, Todd Ditchendorf wrote:
> >
> >> oh... and btw, I don't think the line below is going to work
> >> anyhow... first of all, I think I gave you some bumb advice... I'd
> >> never heard of moveLeft: before... I just looked it up, and it
> >> looks like it's something that an NSTextView might implement, not
> >> an NSWindow.
> >>
> >> More importantly, Allan has developed his own alternative to
> >> NSTextView in TM, called OakTextView, and I would not be surprised
> >> if it doesn't implement that method anyhow, so this might be a
> >> dead end.
> >>
> >> Todd Ditchendorf
> >>
> >> Scandalous Software - Mac XML Developer Tools
> >> http://scan.dalo.us
> >>
> >>
> >>
> >> On Mar 17, 2007, at 3:39 PM, Todd Ditchendorf wrote:
> >>
> >>> Kirt, I've done quite a bit of communication from a tm plugin to
> >>> the TM front most window[1][2][3]... I think you should probably
> >>> try something like this:
> >>>
> >>> [[[NSApplication sharedApplication] mainWindow] moveLeft:self]
> >>>
> >>>
> >>> Note that +[NSApplication sharedApplication] returns an
> >>> NSApplication instance, not a window. An NSApplication handles
> >>> much of the application's lifecycle. A window is represented by
> >>> NSWindow. The frontmost TM editing window can always be fetched
> >>> by calling -[NSApplication mainWindow] on the TM application
> >>> instance from your plugin, as shown above
> >>>
> >>> If I were Allan, I would probably admonish you not to do anything
> >>> too crazy to the frontmost TM window from your plugin, as it
> >>> might surprise users. But then again, as I mentioned, I've
> >>> probably done more peeking under TM's skirt with my plugins than
> >>> anyone else has...  So far Allan hasn't complained ;-]
> >>>
> >>>
> >>> [1] http://ditchnet.ort/texmlmate
> >>> [2] http://ditchnet.ort/texslmate
> >>> [3] http://ditchnet.ort/blogmate
> >>>
> >>>
> >>> Todd Ditchendorf
> >>>
> >>> Scandalous Software - Mac XML Developer Tools
> >>> http://scan.dalo.us
> >>>
> >>>
> >>>
> >>> On Mar 17, 2007, at 2:52 PM, Kirt Fitzpatrick wrote:
> >>>
> >>>> I am trying to call the moveLeft method on the editor window and
> >>>> I don't seem to be having any luck.  I am a bit of a n00b to
> >>>> Objective C so I assume that I must be missing something.  This
> >>>> is what I came up with.  Am I doing something wrong?
> >>>>
> >>>> SEL methodSelector = sel_registerName( "moveLeft" );
> >>>> [[NSApplication sharedApplication] sendAction:methodSelector
> >>>> to:nil from:self];
> >>>>
> >>>> kirt
> >>>>
> >>>> _______________________________________________
> >>>> textmate-plugins mailing list
> >>>> textmate-plugins@...
> >>>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
> >>>
> >>> _______________________________________________
> >>> textmate-plugins mailing list
> >>> textmate-plugins@...
> >>> http://lists.macromates.com/mailman/listinfo/textmate-plugins
> >>
> >> _______________________________________________

> >> textmate-plugins mailing list
> >> textmate-plugins@...
> >> http://lists.macromates.com/mailman/listinfo/textmate-plugins
> >
> > _______________________________________________
> > textmate-plugins mailing list
> > textmate-plugins@...
> > http://lists.macromates.com/mailman/listinfo/textmate-plugins
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins
>
> _______________________________________________
> textmate-plugins mailing list
> textmate-plugins@...
> http://lists.macromates.com/mailman/listinfo/textmate-plugins

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins


_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Allan Odgaard-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 17. Mar 2007, at 23:55, Todd Ditchendorf wrote:

> [...] I've peeked into the OakTextView.h header file using class-
> dump[1], and I don't see moveLeft: listed there. I really don't  
> think this will work.

OakTextView does implement the majority of NSResponder mehtods.  
However, they are virtual in the sense that you need to use  
performSelector:withObject: or something like NSApplication’s  
sendAction:to:from:.

As for using “undocumented methods”: all of NSResponder is safe,  
since that will also exist in 2.0 -- for the rest, 2.0 will use a new  
OakTextView with an overall much changed (and cleaned up ;) ) API, at  
that time, the API will be made public, and plug-ins will also be  
able to use custom instances of the view.

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Todd Ditchendorf-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> On 17. Mar 2007, at 23:55, Todd Ditchendorf wrote:
>
>> [...] I've peeked into the OakTextView.h header file using class-
>> dump[1], and I don't see moveLeft: listed there. I really don't  
>> think this will work.
>
> OakTextView does implement the majority of NSResponder mehtods.  
> However, they are virtual in the sense that you need to use  
> performSelector:withObject: or something like NSApplication’s  
> sendAction:to:from:.

wow, cool. I stand humbly corrected. this is good to know.

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Kirt Fitzpatrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


OakTextView does implement the majority of NSResponder mehtods.
However, they are virtual in the sense that you need to use
performSelector:withObject: or something like NSApplication's
sendAction:to:from:.

If this is true than how come Todd and Rob's suggestions for sendAction do not work?

[[NSApplication sharedApplication] sendAction: @selector(moveLeft:) to: nil from: self];
-- or --
[[[NSApplication sharedApplication] mainWindow] moveLeft:self]


thanks,
kirt


_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Allan Odgaard-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 18. Mar 2007, at 01:31, Kirt Fitzpatrick wrote:

>> OakTextView does implement the majority of NSResponder mehtods. [...]
> If this is true than how come Todd and Rob's suggestions for  
> sendAction do not work?
>
> [[NSApplication sharedApplication] sendAction: @selector(moveLeft:)  
> to: nil from: self];
> -- or --
> [[[NSApplication sharedApplication] mainWindow] moveLeft:self]

The latter surely should not work. The former, maybe because your  
plug-in opens a window that interferes with the responder chain? Or  
some other problem in the code? It is hard to diagnose without seeing  
the full source.

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Kirt Fitzpatrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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).  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


_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: sendAction Question

by Kirt Fitzpatrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
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@...> 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).  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



_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins