pharo-users@lists.pharo.org

Any question about pharo is welcome

View all threads

Create keyboard shortcut

M
mspgate@gmail.com
Wed, Oct 20, 2021 8:53 AM

Hello everybody,

how would I create a keyboard shortcut for a method I have defined in my class or package?

for example if I would like to have a keyboard shortcut for a method that opens the Transcript and display the “Hello I am the new shortcut” message?

thanks for the help.

peace.d

Hello everybody, how would I create a keyboard shortcut for a method I have defined in my class or package? for example if I would like to have a keyboard shortcut for a method that opens the Transcript and display the “Hello I am the new shortcut” message? thanks for the help. peace.d
GP
Guillermo Polito
Wed, Oct 20, 2021 10:04 AM

Hi peace.d,

I’ve had a quick look: you can inspire yourself from the class ToolShortcutsCategory.

The class has a couple of special things:

  • it inherits from KMCategory (a keymapping framework class)
  • it defines isGlobal returning true on the class side (to say it defines global shortcuts)
  • it then has methods defining shortcuts:

openUnitTestRunner
<shortcut>
^ KMKeymap shortcut: PharoShortcuts current openTestRunnerShortcut action: [ Smalltalk tools openTestRunner ]

If you want a shortcut only to be active on a particular tool/window, AND you’re using morphic, take a look at the methods in the Morph class related to keymappings:

Cheers,
Guille

El 20 oct 2021, a las 10:53, mspgate@gmail.com escribió:

Hello everybody,

how would I create a keyboard shortcut for a method I have defined in my class or package?

for example if I would like to have a keyboard shortcut for a method that opens the Transcript and display the “Hello I am the new shortcut” message?

thanks for the help.

peace.d

Hi peace.d, I’ve had a quick look: you can inspire yourself from the class ToolShortcutsCategory. The class has a couple of special things: - it inherits from KMCategory (a keymapping framework class) - it defines `isGlobal` returning true on the class side (to say it defines global shortcuts) - it then has methods defining shortcuts: openUnitTestRunner <shortcut> ^ KMKeymap shortcut: PharoShortcuts current openTestRunnerShortcut action: [ Smalltalk tools openTestRunner ] If you want a shortcut only to be active on a particular tool/window, AND you’re using morphic, take a look at the methods in the Morph class related to keymappings: Cheers, Guille > El 20 oct 2021, a las 10:53, mspgate@gmail.com escribió: > > Hello everybody, > > how would I create a keyboard shortcut for a method I have defined in my class or package? > > for example if I would like to have a keyboard shortcut for a method that opens the Transcript and display the “Hello I am the new shortcut” message? > > > > thanks for the help. > > peace.d >
M
mspgate@gmail.com
Wed, Oct 20, 2021 8:17 PM

thanks a lot Guille, this is a good tip!

thanks a lot Guille, this is a good tip!