Excellent Nicolai, thanks for the detailed answer! Now I have everything 
working exactly as I want it to be, so I’m happy :-)

(Also, alex, thanks for pointing out the tab in the inspector, but I think I 
would have not found it since the morph is embedded in a Spec window so it 
would have been even deeper in the hierarchy.)

> On Oct 28, 2015, at 20:04, Nicolai Hess <nicolaih...@gmail.com> wrote:
> 
> 
> 
> 2015-10-28 23:56 GMT+01:00 Aliaksei Syrel <alex.sy...@gmail.com 
> <mailto:alex.sy...@gmail.com>>:
> You can use the power of Inspector! Inspect rubric morph and you will see 
> there is shortcuts tab which lists all assigned shortcuts and if you click on 
> one them a new tab will be opened to the right showing exact place in source 
> code when shortcut is defined and its action.
> 
> 
> This does not really help if you don't know which morph actually gets the 
> shortcut definitions.
> In my example I did the same mistake, even if you instantiate a 
> RubScrolledTextMORPH the object
> that processes the keyevents is actually a RubEditingArea, accessible through
> (RubScollredTextMorph) self textArea. ( if you are working with a spec 
> TextModel this you need to call it two times
> 
> t:= TextModel new.
> "the textarea is: "
> t textArea textArea " : - ("
> 
>  
> On Oct 28, 2015 11:05 PM, "Johan Fabry" <jfa...@dcc.uchile.cl 
> <mailto:jfa...@dcc.uchile.cl>> wrote:
> Hi Nicolai,
> 
> thanks for your answer! However, apparently the problem is a bit different: 
> the shortcut I wanted to add, cmd-s, already existed but I did not realize 
> it! I want to add cmd-s to save the text to a file, but the editor has auto 
> accept set to true and cmd-s calls accept by default. So adding another cmd-s 
> did not do anything and neither could I see that the existing cmd-s binding 
> was executing some other behavior :-/
> 
> After seeing this, I expected that I would be able to remove the cmd-s 
> keybinding, using removeKeyCombination: but apparently I cannot (see example 
> below). 
> 
> In general, it’s not nice to discover from the code that there are keyboard 
> shortcuts that are not listed in the context menu. The enduser should be able 
> to discover all active keybindings from what is visible in the UI and this is 
> not the case here. Maybe I’ll make a subclass of RubTextEditor that only 
> reimplements buildShortcutsOn: so that it is without all these hidden 
> keybindings.
> 
> But for now I’ll add cmd-d to do save … although that’s ugly. :-(
> 
>     |  window text |
>     text := RubScrolledTextMorph new.
>     
>     "define a custom shortcut"
>     text removeKeyCombination: $s command.
>     text on:$s command do:[
>         text setText: text text asString reverse].
>     
>     window := StandardWindow new.
>     window addMorph: text fullFrame: (0@0 corner: 1@1) asLayoutFrame.
>     window title: 'Example'.
>     window openInWorld.
> 
> @Johan, as above, the "correct" morph for processing the keyevents is the 
> textArea of the RubScrolledTextMorph, 
> this should work 
> 
> 
>     |  window text |
>     text := RubScrolledTextMorph new.
>     
>     "define a custom shortcut  - notice  the call to textArea"
> 
>     text textArea removeKeyCombination: $s command.
>     text textArea on:$s command do:[
>         text setText: text text asString reverse].
> 
>     window := StandardWindow new.
>     window addMorph: text fullFrame: (0@0 corner: 1@1) asLayoutFrame.
>     window title: 'Example'.
>     window openInWorld.
> 



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of 
Chile

Reply via email to