Search in sources :

Example 1 with GutterClickHandler

use of net.codemirror.lib.CodeMirror.GutterClickHandler in project gerrit by GerritCodeReview.

the class DiffScreen method onGutterClick.

private GutterClickHandler onGutterClick(final CodeMirror cm) {
    return new GutterClickHandler() {

        @Override
        public void handle(CodeMirror instance, final int line, final String gutterClass, NativeEvent clickEvent) {
            if (Element.as(clickEvent.getEventTarget()).hasClassName(getLineNumberClassName()) && clickEvent.getButton() == NativeEvent.BUTTON_LEFT && !clickEvent.getMetaKey() && !clickEvent.getAltKey() && !clickEvent.getCtrlKey() && !clickEvent.getShiftKey()) {
                cm.setCursor(Pos.create(line));
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        getCommentManager().newDraftOnGutterClick(cm, gutterClass, line + 1);
                    }
                });
            }
        }
    };
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) GutterClickHandler(net.codemirror.lib.CodeMirror.GutterClickHandler) CodeMirror(net.codemirror.lib.CodeMirror) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Aggregations

ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 NativeEvent (com.google.gwt.dom.client.NativeEvent)1 CodeMirror (net.codemirror.lib.CodeMirror)1 GutterClickHandler (net.codemirror.lib.CodeMirror.GutterClickHandler)1