org.xwiki.gwt.wysiwyg.client.plugin.readonly
Class SafariReadOnlyKeyboardHandler

java.lang.Object
  extended by org.xwiki.gwt.user.client.KeyboardAdaptor
      extended by org.xwiki.gwt.wysiwyg.client.plugin.readonly.ReadOnlyKeyboardHandler
          extended by org.xwiki.gwt.wysiwyg.client.plugin.readonly.SafariReadOnlyKeyboardHandler
All Implemented Interfaces:
com.google.gwt.event.dom.client.KeyDownHandler, com.google.gwt.event.dom.client.KeyPressHandler, com.google.gwt.event.dom.client.KeyUpHandler, com.google.gwt.event.shared.EventHandler

public class SafariReadOnlyKeyboardHandler
extends ReadOnlyKeyboardHandler

Custom implementation of ReadOnlyKeyboardHandler for WebKit-based browsers.

Version:
$Id: cc381c01fd28fcbb20716d62115ea54b2fece740 $

Constructor Summary
SafariReadOnlyKeyboardHandler()
           
 
Method Summary
protected  void moveCaretOutside(com.google.gwt.dom.client.Node node, boolean before)
          Places the caret outside of the specified node, either before or after.
protected  void onDelete(Event event, Element element)
          Deletes a read-only element when it is the only target of the given event.
protected  void onDelete(Event event, Element element, Range range, boolean start)
          Deletes a read-only element when it is not the only target of the given event.
 
Methods inherited from class org.xwiki.gwt.wysiwyg.client.plugin.readonly.ReadOnlyKeyboardHandler
handleRepeatableKey
 
Methods inherited from class org.xwiki.gwt.user.client.KeyboardAdaptor
handleKeyRelease, onKeyDown, onKeyPress, onKeyUp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafariReadOnlyKeyboardHandler

public SafariReadOnlyKeyboardHandler()
Method Detail

onDelete

protected void onDelete(Event event,
                        Element element)
Deletes a read-only element when it is the only target of the given event.

WebKit browsers don't restore the selection after an element that contained or was touched by the selection is removed. Instead of manually removing the read-only element we select it and let the browser remove it.

Overrides:
onDelete in class ReadOnlyKeyboardHandler
Parameters:
event - the native event that was fired
element - the read-only element to be deleted
See Also:
ReadOnlyKeyboardHandler.onDelete(Event, Element)

onDelete

protected void onDelete(Event event,
                        Element element,
                        Range range,
                        boolean start)
Deletes a read-only element when it is not the only target of the given event.

WebKit browsers don't restore the selection after an element that contained or was touched by the selection is removed. Instead of manually removing the read-only element we extend the given range to include the element and let the browser remove it.

Overrides:
onDelete in class ReadOnlyKeyboardHandler
Parameters:
event - the native event that was fired
element - the read-only element to be deleted
range - the range that touches the read-only element
start - true if the start point of the given range is inside the read-only element, false if the end point is inside the read-only element
See Also:
ReadOnlyKeyboardHandler.onDelete(Event, Element, Range, boolean)

moveCaretOutside

protected void moveCaretOutside(com.google.gwt.dom.client.Node node,
                                boolean before)
Places the caret outside of the specified node, either before or after.

WebKit browsers don't keep the caret where we put it (before/after the macro container) so we have to add a text node and select it to be sure the caret remains outside of the macro.

Overrides:
moveCaretOutside in class ReadOnlyKeyboardHandler
Parameters:
node - a DOM node
before - true to place the caret before the given node, false to place it after


Copyright © 2004–2014 XWiki. All rights reserved.