Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] StyledText and keyboard actions

Hi Thomas,

Have a look at AbstractTextEditor#createNavigationActions. It sounds like it does what you are looking for.

It does:
textWidget.setKeyBinding(SWT.INSERT, SWT.NULL);

And hooks its own VerifyKeyListener and matches keys to actions.

-Gunnar

-- 
Gunnar Wagenknecht
gunnar@xxxxxxxxxxxxxxx, http://guw.io/






> On 2 Feb 2017, at 20:23, Thomas Singer <ts-swt@xxxxxxxxxxx> wrote:
> 
> Hi Leo,
> 
> But the main question is how to tell setKeyBinding what own code should be executed? If I recall correctly, Swing used Actions for that, but here a simple Runnable would do as well.
> 
> How exactly Eclipse injects own shortcuts - assuming that StyledText is the core control for the code editor?
> 
> --
> Best regards,
> Thomas Singer
> =============
> syntevo GmbH
> http://www.syntevo.com
> http://www.syntevo.com/blog
> 
> 
> On 02.02.2017 16:05, Leo Ufimtsev wrote:
>> Hello Thomas,
>> 
>> I've never worked with styled text or remapped keys, but at glance I
>> noticed  the "keyActionMap" variable.
>> There is a getKeyBinding(int) and setKeyBinding(int,int) method.
>> 
>> The createKeyBindings() method initializes all default keybindings (which
>> is called from the constructor).
>> 
>> I haven't experiment with it, but you could perhaps override the default
>> mappings. Like if you look inot the createKyBindings() method:
>> setKeyBinding(SWT.ARROW_UP, ST.LINE_UP);  <<< set these to some of your own.
>> 
>> I don't know if this is what you need or if the above works thou? Is that
>> of any use?
>> 
>> If someone knows of a better approach, please feel free to post.
>> 
>> Regards
>> 
>> Leo
>> 
>> 
>> 
>> 
>> On Thu, Feb 2, 2017 at 7:38 AM, Thomas Singer <ts-swt@xxxxxxxxxxx> wrote:
>> 
>>> Hi,
>>> 
>>> Currently we are using an ugly hack to modify the behavior of some default
>>> shortcuts and add own shortcuts in a StyledText by having a subclass of
>>> StyledText inside org.eclipse.swt.custom and overriding the method
>>> invokeAction(int actionId).
>>> 
>>> For example, we can cut/copy without selection or limit cursor-left/-right
>>> to the very line, have a more advanced delete-previous or Mac-like handling
>>> of cursor-up/-down.
>>> 
>>> What is the designed way of
>>> - replacing default shortcuts with own ones and
>>> - add new shortcuts?
>>> 
>>> Thanks in advance.
>>> 
>>> --
>>> Best regards,
>>> Thomas Singer
>>> =============
>>> syntevo GmbH
>>> http://www.syntevo.com
>>> http://www.syntevo.com/blog
>>> _______________________________________________
>>> platform-swt-dev mailing list
>>> platform-swt-dev@xxxxxxxxxxx
>>> To change your delivery options, retrieve your password, or unsubscribe
>>> from this list, visit
>>> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> platform-swt-dev mailing list
>> platform-swt-dev@xxxxxxxxxxx
>> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
>> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>> 
> _______________________________________________
> platform-swt-dev mailing list
> platform-swt-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top