[Pharo-users] How to add a keyboard shortcut to Rubric?
nicolaihess at gmail.com
Wed Oct 28 16:58:20 EDT 2015
2015-10-28 19:59 GMT+01:00 Johan Fabry <jfabry at dcc.uchile.cl>:
> Hi all,
> I am trying to add a keyboard shortcut to a RubTextEditor. I have tried
> different ways but nothing seems to work. I have even tried modifying
> buildShortcutsOn: at class side to include the extra shortcut but it does
> not have any effect at all.
> Ideally I’d take an existing instance and add the keyboard shortcut there,
> but if that is impossible I’m willing to make a subclass just to get this
> extra shortcut. Can anybody give me pointers?
> ---> Save our in-boxes! http://emailcharter.org <---
> Johan Fabry - http://pleiad.cl/~jfabry
> PLEIAD and RyCh labs - Computer Science Department (DCC) - University
> of Chile
adding a custom shortcut for a Rubric-TextMorph is easy:
| window text |
text := RubWorkspaceExample new newScrolledText.
"define a custom shortcut"
text on:$t command do:[
text setText: text text asString reverse].
window := StandardWindow new.
window addMorph: text fullFrame: (0 at 0 corner: 1 at 1) asLayoutFrame.
window title: 'Example'.
This simple example will build a Rubric Scrolled Textmorph and add a
alt+t shortcut to reverse the current text
What ways did you already tried?
Modifying the existing #buildShortcuts method should work, for existing
RubTextEditor (or subclasses).
But if you define your own RubTextEditor you may need to define another
shortcut category and register your editor with that
category on the Morph you use.
For example, RubAbstractTextArea (a Morph) calls
super initializeShortcuts: aKMDispatcher.
self editor initializeShortcuts: aKMDispatcher
and teh editors #initializeShortcuts
will attach the editors category, defined in the editors class side
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-users