Add my custom menu item to the Tools menu

61 views
Skip to first unread message

Hernán Morales Durand

unread,
May 20, 2020, 4:34:56 PM5/20/20
to va-sma...@googlegroups.com
Hi everyone,

I'm using VA Smalltalk 9.1.
It is possible in this version to add my own menu item to the Tools menu in the System Transcript window?

Normally I would search the strings in the image to see how it's done but I didn't found any shortcut.
Any example would be appreciated.

Cheers,

Hernán

Mariano Martinez Peck

unread,
May 20, 2020, 4:54:58 PM5/20/20
to VA Smalltalk
Hernan, sorry for the question but by "shortcut" you mean a way to get quicking to the place in code that defines the menu entry, or to add keyboard shortcuts to that menu entry? I guess the former, but just in case....

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to va-smalltalk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/CAKHmnHsYkQ2vo9tWhATEhNiUKFuXmh072ELbcyt33aboiFW6dw%40mail.gmail.com.


--
Mariano Martinez Peck
Software Engineer, Instantiations Inc.

Mariano Martinez Peck

unread,
May 20, 2020, 5:02:10 PM5/20/20
to VA Smalltalk
BTW, you may want to take a look at implementers of #addToSystemMenu.  
One simple example is the configuration map "Mastering ENVY/ Developer Script Manager". Once loaded, check the class side methods of MedScriptManagerApp.
Does it help?

Best, 

Hernán Morales Durand

unread,
May 20, 2020, 5:11:30 PM5/20/20
to va-sma...@googlegroups.com
Hi Mariano,

With shortcut I mean a way (keys combination) to type a String anywhere and find it in the image, just as the Ctrl+Shift+E in Pharo/Squeak.
It is not directly related to the menu entry, but any String in the image.

Mariano Martinez Peck

unread,
May 20, 2020, 5:34:26 PM5/20/20
to VA Smalltalk
Hi Hernan,

So....are you talking about the:

Browse Methods -> Including String ... 

?

Richard Sargent

unread,
May 20, 2020, 5:48:55 PM5/20/20
to VA Smalltalk
On Wednesday, May 20, 2020 at 1:34:56 PM UTC-7, Hernán Morales Durand wrote:
Hi everyone,

I'm using VA Smalltalk 9.1.
It is possible in this version to add my own menu item to the Tools menu in the System Transcript window?

Normally I would search the strings in the image to see how it's done but I didn't found any shortcut.

See the attached screen print. It is from the Transcript window, but I believe the same menu item is available on most development tools windows.

Likewise, the accelerator sequences are associated with the menus of each window. As far as I know, there is no global accelerator sequences.
e.g. Ctrl+S typically triggers the Save menu item from the File menu. Ctrl+C triggers the Copy menu item from the Edit menu. In the absence of these menus, the corresponding key sequence has no effect (unless some other menu on that window defines a binding).

Mariano Martinez Peck

unread,
May 20, 2020, 6:52:43 PM5/20/20
to VA Smalltalk
Richard, I don't see any attachment, 

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to va-smalltalk...@googlegroups.com.

Richard Sargent

unread,
May 20, 2020, 7:37:26 PM5/20/20
to VA Smalltalk
On Wednesday, May 20, 2020 at 3:52:43 PM UTC-7, Mariano Martinez Peck wrote:
Richard, I don't see any attachment, 

Doh!
Added here.


On Wed, May 20, 2020 at 6:48 PM Richard Sargent <richard...@gemtalksystems.com> wrote:
On Wednesday, May 20, 2020 at 1:34:56 PM UTC-7, Hernán Morales Durand wrote:
Hi everyone,

I'm using VA Smalltalk 9.1.
It is possible in this version to add my own menu item to the Tools menu in the System Transcript window?

Normally I would search the strings in the image to see how it's done but I didn't found any shortcut.

See the attached screen print. It is from the Transcript window, but I believe the same menu item is available on most development tools windows.

Likewise, the accelerator sequences are associated with the menus of each window. As far as I know, there is no global accelerator sequences.
e.g. Ctrl+S typically triggers the Save menu item from the File menu. Ctrl+C triggers the Copy menu item from the Edit menu. In the absence of these menus, the corresponding key sequence has no effect (unless some other menu on that window defines a binding).


Any example would be appreciated.

Cheers,

Hernán

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to va-sma...@googlegroups.com.
FindString.png

Hernán Morales Durand

unread,
May 20, 2020, 10:43:24 PM5/20/20
to va-sma...@googlegroups.com
Yes thanks Mariano.
I am already playing with it.

Cheers!

Hernán

Hernán Morales Durand

unread,
May 20, 2020, 10:44:35 PM5/20/20
to va-sma...@googlegroups.com
Hi Richard,

Cool, I was just looking at the wrong place.
Thank you!

Hernán

To unsubscribe from this group and stop receiving emails from it, send an email to va-smalltalk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/01d48ae9-f27b-4729-8a6a-f493da31c8f1%40googlegroups.com.

Mariano Martinez Peck

unread,
May 21, 2020, 10:27:13 AM5/21/20
to VA Smalltalk
Hernán, 

I think what you said makes sense and it's quite easy to implement. I just did a quick prototype which we could eventually include in the next release. Please, give it a try:

Add these 2 methods:

EmSystemConfiguration >> stsMethodsIncluding: aString

"Open a browser on all the methods including aString specified by the user."


(aString isNil or: [aString isEmpty])

ifTrue: [self stsMethodsIncludingString]

ifFalse: [

(System stsConfirm: 'This is a very lengthy operation. Continue?' title: 'Find String')

ifFalse: [^self].

self stsAllMethodsIncludingString: aString]


EtWindow >> stsMethodsIncludingString

"Open a browser on all the methods including aString specified by the user."


| text widget |


self convertSelectionText: (widget := self targetTextWidget).

text := widget getSelection.

System stsMethodsIncluding: text



And then change EtWindow >> stsEditMenu:   and add the following at the end of the method:

add: #stsMethodsIncludingString

label: 'Browse Methods Including String'

enable: [true]

for: nil

accelerator: (CwAccelerator mask: ControlMask | ShiftMask keysym: XKe)

acceleratorText: 'Ctrl+Shift+E';



The behavior should be: If you have text selected, then it will search on that. If you have nothing selected, then it will prompt. 

Let me know if it works. 

Cheers, 



Simon Franz

unread,
May 21, 2020, 5:22:29 PM5/21/20
to VA Smalltalk
+1 for a default implementation for this action with CTRL+Shift+E ;-)

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to va-sma...@googlegroups.com.

Mariano Martinez Peck

unread,
May 21, 2020, 5:28:55 PM5/21/20
to VA Smalltalk
Cool. So let me know if what I sent works as expected and if so, I can integrate it for next release.
BTW, I may prefer CTRL+SHIFT+F rather than "E" as we already have "CTRL+F" for "Find". 
Opinions?

To unsubscribe from this group and stop receiving emails from it, send an email to va-smalltalk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/2ef482fa-38c4-43a2-9125-2d062d3c4ff7%40googlegroups.com.

Richard Sargent

unread,
May 21, 2020, 5:33:35 PM5/21/20
to VA Smalltalk
On Thu, May 21, 2020 at 2:28 PM 'Mariano Martinez Peck' via VA Smalltalk <va-sma...@googlegroups.com> wrote:
Cool. So let me know if what I sent works as expected and if so, I can integrate it for next release.
BTW, I may prefer CTRL+SHIFT+F rather than "E" as we already have "CTRL+F" for "Find". 

I like that. Ctrl+F finds in the current text pane (if there is one) and Ctrl+Shift+F finds everywhere in the image.
Good use of Shift to convey scope.

You received this message because you are subscribed to a topic in the Google Groups "VA Smalltalk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/va-smalltalk/Q4gjsFTx1E4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to va-smalltalk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/CAOUkibF6Pc0WJgi2WK3AgBavg-pCqyUTayGfJjnXXHgxNSERxw%40mail.gmail.com.

Seth Berman

unread,
May 21, 2020, 5:36:21 PM5/21/20
to VA Smalltalk
Great enhancement idea!

+1 to "Ctrl+Shift+F"


- Seth
Opinions?

To unsubscribe from this group and stop receiving emails from it, send an email to va-smalltalk+unsubscribe@googlegroups.com.


--
Mariano Martinez Peck
Software Engineer, Instantiations Inc.

--
You received this message because you are subscribed to a topic in the Google Groups "VA Smalltalk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/va-smalltalk/Q4gjsFTx1E4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to va-smalltalk+unsubscribe@googlegroups.com.

Hernán Morales Durand

unread,
May 21, 2020, 9:41:42 PM5/21/20
to va-sma...@googlegroups.com
I'd like to suggest to distinguish between searching any kind of literals inside a method, and search only in the real Strings contained in a method, which is what I expected as default behavior. For example if you highlight Breakpoints in a Workspace and Ctrl+Shift+E, now it returns all the methods with the subword Breakpoint, even if it is part of a Symbol, i.e. in this method:

>>stsClearBreakpoints
   super stsClearBreakpoints.
   sourceCodeNotebook
   callCallbacks: XmNresizeCallback
   callData: nil.

the results includes literals containing "Breakpoints" as substrings: stsClear"Breakpoints", they don't make a distinction if it is a real String or a message send.
Anyway, I tested with a dummy method:

>>sampleMethod

^ 'myBreakpoint'
 
And it returns 1 result as expected, so ultimately it works :)

Thank you Mariano


Hernán Morales Durand

unread,
May 21, 2020, 9:57:18 PM5/21/20
to va-sma...@googlegroups.com
My 0.0002 devalued ARS is to provide al least two methods: One keybinding for exact String search and one for approximate search up to k mismatches. There are different algorithms depending if you want to consider diacritics, capital letters, phrases, or even k, and speed (Levenshtein could be really slow).
Cheers

Hernán

Mariano Martinez Peck

unread,
May 22, 2020, 2:48:39 PM5/22/20
to VA Smalltalk


I'd like to suggest to distinguish between searching any kind of literals inside a method, and search only in the real Strings contained in a method, which is what I expected as default behavior. For example if you highlight Breakpoints in a Workspace and Ctrl+Shift+E, now it returns all the methods with the subword Breakpoint, even if it is part of a Symbol, i.e. in this method:

>>stsClearBreakpoints
   super stsClearBreakpoints.
   sourceCodeNotebook
   callCallbacks: XmNresizeCallback
   callData: nil.

the results includes literals containing "Breakpoints" as substrings: stsClear"Breakpoints", they don't make a distinction if it is a real String or a message send.
Anyway, I tested with a dummy method:

>>sampleMethod

^ 'myBreakpoint'
 
And it returns 1 result as expected, so ultimately it works :)



We already have both. The one that looks in all source code is the one you already knew and we already discussed in this thread. This is usually the "slow one" but matches everything. 

But...we also have one that only look for "references" (literals, etc). Go to Transcript -> Tools -> Browse References. And there, type the string, number or whatever you want. 

Let me know if that's what you were looking for. 

Best, 

Hernán Morales Durand

unread,
Jun 15, 2020, 1:36:22 AM6/15/20
to va-sma...@googlegroups.com
Sorry for the late feedback on this.

A small problem which you may want to check is that if I use #addToSystemMenu then some "Tools" menu items are duplicated.
So I had to use a different callback name.
Thank you Mariano.

Cheers,

Hernán

Captura de pantalla 2020-06-11 a la(s) 19.25.20.png
Reply all
Reply to author
Forward
0 new messages