Re: Create custom key board shortcut keys

1 message Options
Embed this post
Permalink
Adrian Sutton

Re: Create custom key board shortcut keys

Reply Threaded More More options
Print post
Permalink
On 15 Oct 2009, at 12:35, debxone wrote:
> I want create custom shortcut keys which will perform applying the  
> styles.
>
> For ex: Crtl +1 = Apply css style "st1" on selected text
> Crtl +2 = Apply css style "st2" on selected text
>
> I am using editlive java sdk.

Hi DP,
Unfortunately, the only way to achieve that with the current API is to  
use the DocumentModifier and apply the class attribute yourself.  
There isn't a simple event that can be fired.

To add a span tag, the invocation would be something like:

int startOffset = eljBean.getHTMLPane().getSelectionStart();
int endOffset = eljBean.getHTMLPane().getSelectionEnd();

SimpleAttributeSet add = new SimpleAttributeSet();
SimpleAttributeSet spanAttributes = new SimpleAttributeSet();
spanAttributes.addAttribute(HTML.Attribute.CLASS, "st1");
add.addAttribute(HTML.Tag.SPAN, spanAttributes);
eljBean.getDocumentModifier().adjustCharacterAttributes(startOffset,  
endOffset, add, Collections.EMPTY_LIST);

A good example of doing this kind of thing is the AutoLink plugin  
(which comes with source).  We have an article walking through the  
code at http://liveworks.ephox.com/hints-tips/automatically-linking-urls

Also see the JavaDoc for the DocumentModifier class which is the key  
to modifying content within EditLive!
http://liveworks.ephox.com/documentation/editliveswingsdk/v60/javadoc/com/ephox/editlive/java2/editor/DocumentModifier.html

Regards,

Adrian Sutton.
______________________
Adrian Sutton, CTO
UK: +44 1 628 353 032  US: +1 (650) 292 9659 x717
Ephox <http://www.ephox.com/>
Ephox Blogs <http://planet.ephox.com/>, Personal Blog <http://www.symphonious.net/ 
 >

_______________________________________________
[hidden email]
List instructions at http://liveworks.ephox.com/mailing-list/