[Newbies] Re: Adding menu options to Omnibrowser

Zulq Alam me at zulq.net
Sun May 24 19:25:03 UTC 2009

Hi Rob,

I haven't done this in a while but I believe you need to do this:

- Create a subclass of OBCommand. This class will be responsible for 
indicating when the menu option should be shown, how it is shown and how 
it should be performed. I think there's more, but I don't know what.

- Implement #isActive to indicate when your menu option should be shown. 
For example, I think this will limit you to class side methods:

   ^ (target isKindOf: OBMethodNode)
     and: [(target classNode isKindOf: OBMetaclassNode)
       and: [requestor isSelected: target]]

You may want to add a constraint to limit this to unary selectors 
otherwise you'll have to prompt for arguments.

- Implement #execute. This will actually do the work. If you're just 
dealing with unary methods then something like this is probably what you 

   target theNonMetaClass perform: target selector

So here you could prompt for arguemnts, inspect the result, do whatever.

- Implement #label, #longDescription, #group, #keystroke to control the 
display of your menu. Have a look at the other OBCommand subclasses for 

- Link up your command by adding a cmdXXX method to OBCodeBrowser. 
Basically you need a method like:


Have a look at the "commands" protocol to see what I mean.

The next browser you open should have your new menu option. There are 
many existing OBCommand subclasses you can examine for inspiration.

Hope this helps,

Rob Rothwell wrote:
> I thought it would be nice to add a right click option to class methods 
> that "ran" that method...for use with examples and such.
> So, for example, instead of typing "MyClass exampleThisOrThat," when 
> browsing you could just right click and "run it."
> Any tips on where to start?  I have no knowledge of OB...
> Rob
> ------------------------------------------------------------------------
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

More information about the Beginners mailing list