Hi,

Indeed, I just found the solution on your blog (I should have searched sooner) 
:).

For the PluggableTextMorph, I simply did:
pluggableTextMorph textMorph on: $s command do: [ ... ]

and it just worked. Nice.

Thanks,
Doru


On Mar 24, 2013, at 10:05 PM, Guillermo Polito <guillermopol...@gmail.com> 
wrote:

> 
> 
> On Sun, Mar 24, 2013 at 8:55 PM, Tudor Girba <tu...@tudorgirba.com> wrote:
> Hi,
> 
> I am trying to redefine shortcuts such as Cmd+s for an instance of 
> PluggableTextMorph, but I cannot find a way.
> 
> Now that we have Kemappings in the image, I see that Cmd+s is defined in:
> TextMorph>>buildTextEditorKeymapsOn: aBuilder
>         <keymap>
> 
>         (aBuilder shortcut: #accept)
>                 category: #TextMorph
>                 default: $s ctrl win | $s ctrl unix | $s command mac
>                 do: [ :morph | morph acceptContents ].
> 
>         aBuilder attachShortcutCategory: #TextMorph to: TextMorph.
> 
> 
> Nice, but this defines a behavior that is global to the TextMorph class.
> 
> The Keymappings extensions from Morph do allow some degree of morph specific 
> shortcuts, but it seems that the only thing I can do is:
> - create a category with my keymappings; the category must have a name
> - registered it the dispatcher
> - tell the morph to attach this category by passing the name of the category
> 
> I could not get a code that sets this up because I stumbled across too much 
> symbol-based indirection. Can anyone help?
> 
> You can also try to do:
> 
> aMorph on: $s cmd do: [ "my custom code" ].
> 
> The only thing is that PluggableTextmorph+friends are a bit of a mess, so the 
> code that initializes the shortcuts is here:
> 
> PluggableTextMorph>>configureTextMorph: aTextMorph
>       "I prepare a text morph for use"
>       aTextMorph setEditView: self.
>       scroller addMorph: aTextMorph.
>       aTextMorph 
>               autoAccept: self autoAccept;
>               selectionColor: self selectionColor.
>       aTextMorph editor installKeymappingsOn: self.
> 
> There you can customize...
> 
> Tell me if that helps!
> Guille
>  
> 
> Cheers,
> Doru
> 
> 
> --
> www.tudorgirba.com
> 
> "In a world where everything is moving ever faster,
> one might have better chances to win by moving slower."
> 
> 
> 
> 
> 

--
www.tudorgirba.com

"From an abstract enough point of view, any two things are similar."




Reply via email to