[TxMt] Context menu: Help me get my mind around this...

Hans-Jörg Bibiko bibiko at eva.mpg.de
Thu Oct 4 06:35:11 UTC 2007


On 03.10.2007, at 08:20, Neil Baylis wrote:
> Allan Odgaard-2 wrote:
>> In that light, adding a command to “lookup references” does not make
>> sense, because there will be 10+ different ways to do that, based on
>> context.
>> Yes, I agree with you. I'm thinking of something much simpler.  
>> Just allow a
> bundle to add an arbitrary item to the context menu. When the user  
> selects
> the item, it would trigger a command. If it's possible to trigger a  
> command
> from a keystroke, then it's possible to trigger the same command by
> selecting a menu item. In the bundle editor, there's an 'Action:'  
> dropdown
> that has two choices: 'Key Equivalent' or 'Tab Trigger'. I'm just  
> suggesting
> that you put a third option in there: 'Context Menu Item'.
>
> Of course, this is mainly of value to those of us who use a mouse  
> with more
> than one button. I have no idea what proportion of Textmate users that
> amounts to, so maybe it's a moot point. (If I had to hit the  
> keyboard to get
> the context menu, I could just as well bind the action to a  
> keystroke).

I went this way by using a NSOtherMouseDown command, meaning the  
middle mouse button (scroll wheel).
I wrote a small plugin which adds a eventhandle for NSOtherMouseDown.  
If one click the middle button it will call as default a tmCommand  
'OTHERMOUSEDOWNCOMMAND'. In that script you can put any commands in  
(e.g. as "$DIALOG" -u inline pulldown menu) as you like. For me, I  
wrote a command which asks for the current language (Plain Text,  
Ruby, ...). Depending on that language I have different menus -  
meaning different 'context sensitive menus'. Furthermore I always ask  
whether the cursor is in an OakTextView, if yes the  
OTHERMOUSEDOWNCOMMAND will be executed otherwise not in order to  
avoid unstableness.
To switch this behaviour on/off I created a new key in the  
com.macromates.plist. And you can rebind the executed script on runtime.

I also tried this with NSRightMouseDown event. In principal it works,  
but sometimes I have a problem with NSRunLoop(?).

I'll also put this in the soon coming TMTOOLS plugin.

Hans


More information about the textmate mailing list