[D4Science Infrastructure - Incident #393] Share Updates: users tagging does not work in Firefox

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@117300 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-07-17 10:33:10 +00:00
parent 3e72d59d1c
commit 3943cd1df1
1 changed files with 14 additions and 8 deletions

View File

@ -16,6 +16,8 @@ import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
@ -45,7 +47,7 @@ public class SuperPosedTextArea extends TextArea {
*/
public SuperPosedTextArea() {
sinkEvents(Event.ONPASTE);
sinkEvents(Event.ONKEYPRESS);
//sinkEvents(Event.ONKEYPRESS);
sinkEvents(Event.ONCONTEXTMENU);
sinkEvents(Event.ONKEYDOWN);
sinkEvents(Event.ONKEYUP);
@ -74,6 +76,15 @@ public class SuperPosedTextArea extends TextArea {
getElement().setAttribute("id", "postTextArea");
bind();
this.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
pickUserDlg.onKeyPress(getCursorPos(), event.getUnicodeCharCode(), getAbsoluteLeft(), getAbsoluteTop()+getOffsetHeight(), getText());
pickHashtagDlg.onKeyPress(getCursorPos(), event.getUnicodeCharCode(), getAbsoluteLeft(), getAbsoluteTop()+getOffsetHeight(), getText());
}
});
}
/**
@ -102,11 +113,6 @@ public class SuperPosedTextArea extends TextArea {
t.schedule(100);
break;
}
case Event.ONKEYPRESS: {
pickUserDlg.onKeyPress(this.getCursorPos(), event.getKeyCode(), this.getAbsoluteLeft(), this.getAbsoluteTop()+this.getOffsetHeight(), getText());
pickHashtagDlg.onKeyPress(this.getCursorPos(), event.getKeyCode(), this.getAbsoluteLeft(), this.getAbsoluteTop()+this.getOffsetHeight(), getText());
break;
}
case Event.ONKEYUP: {
injectInDiv(getText());
pickUserDlg.onKeyUp(event.getKeyCode());
@ -149,7 +155,7 @@ public class SuperPosedTextArea extends TextArea {
DOM.getElementById("highlighter").setInnerHTML("");
}
private void injectInDiv(String textAreaText) {
GWT.log("# injectInDiv: "+textAreaText);
//GWT.log("# injectInDiv: "+textAreaText);
String text;
// parse the text:
// replace all the line breaks by <br/>, and all the double spaces by the html version &nbsp;
@ -193,7 +199,7 @@ public class SuperPosedTextArea extends TextArea {
String preceedingPart = getText().substring(0, event.getItemCursorIndexStart());
String afterPart = getText().substring(event.getItemCursorIndexEnd()+1);
setText(preceedingPart + toAdd + " " + afterPart);
injectInDiv(getText());