Hi!
I'm writing simple wysiwyg editor, but can't get createlink function
(from extended formatter) to work under firefox. In internet explorer,
opera everything works fine. I have RichTextArea, toolbar (almost the
same as in ShowCase), DialogBox objects. When user click the "create
link" button from toolbar, dialogbox shows, user enters some data and
pressess ok button. There was a problem with loosing selected text
when dialogbox showed so I wrote some JSNI functions:
private native void getRange(Element element)/*-{
if (element.contentWindow.getSelection) {
var selection = element.contentWindow.getSelection();
if (selection.rangeCount > 0) {
var selectedRange = selection.getRangeAt(0);
element.storedSelection = selectedRange.cloneRange();
}
}
else if (element.contentWindow.document.selection) {
var selection = element.contentWindow.document.selection;
if (selection.type.toLowerCase() == 'text') {
element.storedSelection =
selection.createRange().getBookmark();
}
}
}-*/;
private native void setSelection(Element element)/*-{
if (element.storedSelection) {
if (element.contentWindow.getSelection) {
var selection = element.contentWindow.getSelection();
selection.removeAllRanges();
selection.addRange(element.storedSelection);
}
else if (element.contentWindow.document.selection
&&
element.contentWindow.document.body.createTextRange) {
var range =
element.contentWindow.document.body.createTextRange();
range.moveToBookmark(element.storedSelection);
range.select();
}
}
}-*/;
These methods're called from listener object (inner class in
RichTextToolBar). When user press the createLink button:
else if (sender == createLink) {
getRange(richText.getElement()); //remember selection
popup = new RichTextToolBarPopUp(listener); //show dialogbox
}
and when user press the okButton on DialogBox:
else if (sender == popup.getOkButton()) {
popup.kill(); // hide dialogbox
setSelection(richText.getElement()); //restore selection
extended.createLink(popup.getUrl());
}
Under firefox getRange and setSelection functions works properly. I
can even click on RichTextArea when DialogBox is open and select
another text. When I confirm dialogbox it will select proper text
again, however it won't create a hyperlink. :( Please give me some
hints what could be wrong.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---