Re: code to retrieve all method categories and methods under a category
On Jan 15, 2020, at 1:26 PM, tty wrote:
> Hi All.
> I want to dynamically build a drop-down menu in Seaside based on the
> instance side methods I have in a class.
Have you looked at the Seaside sample code for the WABrowser? On some Seaside images it will be registered at tools/classbrowser by default. I believe it uses a normal Browser as its model, so that's where to go to find out what's actually going on in the background.
> I have been hunting for over an hour and I see no obvious way to retrieve
> this info (I have found a way to get all the methods, but not the category
> that houses them.
> Any help much appreciated.
Have you looked at ClassOrganizer and ClassDescription?
[resent due to attachment limit, sorry for the delay!]
not sure if your question has already been answered, but maybe this approach can help you in general to find answers to problems like these. Let's dive into some reverse engineering tools of Squeak!
First, start a normal System Browser and open the halo on the message category list:
Then open its debug menu by clicking the wrench icon and choose "browse action code":
And you get the method which the list is configured to call in order to get its contents:
By selecting #rawMessageCategoryList and pressing <cmd>m, you also get the second screenshot where you can see that your desired method is named #categories. Select #classOrMetaClassOrganizer and press <cmd>m again to find out where the organizer comes
Okay, this is stored as an instance variable, but how is it set? Right-click the message from the list and choose "assignments..." (you can also do this in any class browser, btw). Next, select classOrganizer from the list.
And you will find:
So your script might look like this: MyClass organization categories.
I hope this might help you to answer future questions! And please forgive me if I told you something you already knew :-)
Have a nice time with Squeak!
Von: Beginners <[hidden email]> im Auftrag von tty <[hidden email]> Gesendet: Mittwoch, 15. Januar 2020 20:26 Uhr An:[hidden email] Betreff: [Newbies] code to retrieve all method categories and methods under a category
I want to dynamically build a drop-down menu in Seaside based on the
instance side methods I have in a class.
#MyClass has method categories: "Attributes Links Paragraph....etc"
Under Method category Links are methods #testLinkCategory,
I have been hunting for over an hour and I see no obvious way to retrieve
this info (I have found a way to get all the methods, but not the category
that houses them.
The code I have in mind has form:
*categories := categoriesFor: #MyClass.
categories do:[:cat | |methods|
methods := methodForClass:#MyClass category: cat.
methods do:[:m |
"dynamically build my html here"