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? Cheers, Doru -- www.tudorgirba.com "In a world where everything is moving ever faster, one might have better chances to win by moving slower." |
On Sun, Mar 24, 2013 at 8:55 PM, Tudor Girba <[hidden email]> wrote: Hi, 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
|
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 <[hidden email]> wrote: > > > On Sun, Mar 24, 2013 at 8:55 PM, Tudor Girba <[hidden email]> 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." |
In reply to this post by Guillermo Polito
>
> You can also try to do: > > aMorph on: $s cmd do: [ "my custom code" ]. guillermo we will have to fix the api before it spreads :) > > The only thing is that PluggableTextmorph+friends are a bit of a mess, so the code that initializes the shortcuts is here: no a large mess :) Alain is addressing that. Stef |
On Sun, Mar 24, 2013 at 10:15 PM, stephane ducasse <[hidden email]> wrote:
Pharo 2.0 summer? :D
|
:) |
Administrator
|
In reply to this post by Tudor Girba-2
I had trouble there when implementing Vim bindings. What I realized was (from http://forum.world.st/Keymapping-Class-vs-Instance-Targets-tp4639863p4640220.html):
Cheers,
Sean |
Exactly. In fact, every time we start implementing anything we should do it per object, and not per class :). The class should only provide defaults at most.
But in Keymappings we have now: Morph>>detachAllKeymapCategories However, we do not yet have something like detachKey:. Cheers, Doru On Mar 25, 2013, at 10:27 PM, "Sean P. DeNigris" <[hidden email]> wrote: > Tudor Girba-2 wrote >> I am trying to redefine shortcuts such as Cmd+s for an instance of >> PluggableTextMorph > > I had trouble there when implementing Vim bindings. What I realized was > (from > http://forum.world.st/Keymapping-Class-vs-Instance-Targets-tp4639863p4640220.html): > > >> What I want is: each instance gets its own copy of all its maps. If the >> morph instance doesn't have any per-instance customizations, this can >> point to the class defaults to save space (but I think this would be >> premature optimization). However, as soon as the instance differs at all >> from the class defaults, it /must/ have it's own local copy of all the >> maps. I don't want to have to override each shortcut of a category >> attached to the class. I want to detach the category /for just this >> instance/. > > > > > > ----- > Cheers, > Sean > -- > View this message in context: http://forum.world.st/redefining-default-smalltalk-shortcuts-in-pluggable-textmorph-tp4678057p4678260.html > Sent from the Pharo Smalltalk mailing list archive at Nabble.com. > -- www.tudorgirba.com "We cannot reach the flow of things unless we let go." |
In reply to this post by Sean P. DeNigris
Exactly. In fact, every time we start implementing anything we should do it per object, and not per class :). The class should only provide defaults at most.
But in Keymappings we have now: Morph>>detachAllKeymapCategories However, we do not yet have something like detachKey:. Cheers, Doru On Mar 25, 2013, at 10:27 PM, "Sean P. DeNigris" <[hidden email]> wrote: > Tudor Girba-2 wrote >> I am trying to redefine shortcuts such as Cmd+s for an instance of >> PluggableTextMorph > > I had trouble there when implementing Vim bindings. What I realized was > (from > http://forum.world.st/Keymapping-Class-vs-Instance-Targets-tp4639863p4640220.html): > > >> What I want is: each instance gets its own copy of all its maps. If the >> morph instance doesn't have any per-instance customizations, this can >> point to the class defaults to save space (but I think this would be >> premature optimization). However, as soon as the instance differs at all >> from the class defaults, it /must/ have it's own local copy of all the >> maps. I don't want to have to override each shortcut of a category >> attached to the class. I want to detach the category /for just this >> instance/. > > > > > > ----- > Cheers, > Sean > -- > View this message in context: http://forum.world.st/redefining-default-smalltalk-shortcuts-in-pluggable-textmorph-tp4678057p4678260.html > Sent from the Pharo Smalltalk mailing list archive at Nabble.com. > -- www.tudorgirba.com "We cannot reach the flow of things unless we let go." |
Yes, it would be very useful.
Phil 2013/3/26 Tudor Girba <[hidden email]>: > Exactly. In fact, every time we start implementing anything we should do it per object, and not per class :). The class should only provide defaults at most. > > But in Keymappings we have now: > Morph>>detachAllKeymapCategories > > However, we do not yet have something like detachKey:. > > Cheers, > Doru > > > On Mar 25, 2013, at 10:27 PM, "Sean P. DeNigris" <[hidden email]> wrote: > >> Tudor Girba-2 wrote >>> I am trying to redefine shortcuts such as Cmd+s for an instance of >>> PluggableTextMorph >> >> I had trouble there when implementing Vim bindings. What I realized was >> (from >> http://forum.world.st/Keymapping-Class-vs-Instance-Targets-tp4639863p4640220.html): >> >> >>> What I want is: each instance gets its own copy of all its maps. If the >>> morph instance doesn't have any per-instance customizations, this can >>> point to the class defaults to save space (but I think this would be >>> premature optimization). However, as soon as the instance differs at all >>> from the class defaults, it /must/ have it's own local copy of all the >>> maps. I don't want to have to override each shortcut of a category >>> attached to the class. I want to detach the category /for just this >>> instance/. >> >> >> >> >> >> ----- >> Cheers, >> Sean >> -- >> View this message in context: http://forum.world.st/redefining-default-smalltalk-shortcuts-in-pluggable-textmorph-tp4678057p4678260.html >> Sent from the Pharo Smalltalk mailing list archive at Nabble.com. >> > > -- > www.tudorgirba.com > > "We cannot reach the flow of things unless we let go." > > > > |
Free forum by Nabble | Edit this page |