RichTextEditor handling of Focus and Traversal Events [message #1742522] |
Fri, 02 September 2016 16:43 |
Gunnar Adams Messages: 49 Registered: May 2016 |
Member |
|
|
Hi,
our application depends on the detection of FocusOut and FocusIn events.
Our backend server application needs to be notified about field changes which can occur both due to keyboard and mouse navigation. We use the corresponding Focus events to determine things like "Change from field A into field B".
This works fine for standard widgets like the Text widget, but after integrating a new field type which makes use of the RichTextEditor widget (which is based on CKEDITOR), I found, that the RichTextEditor does not generate any focus (or mouse) events. At least a FocusListener attached to the server-side widget is not called.
I tried to register event handlers on the client side in order to be notified when the CKEDITOR instance gets the focus:
rwt.widgets.RichTextEditor = function( properties ) {
bindAll( this, [ "layout", "onReady", "onSend", "onRender", "destroy", "focusInHandler", "focusOutHandler" ] );
this.parent = rap.getObject( properties.parent );
this.element = document.createElement( "div" );
this.parent.append( this.element );
this.parent.addListener( "Resize", this.layout );
this.parent.addListener( "Dispose", this.destroy );
rap.on( "render", this.onRender );
};
onReady : function() {
this.ready = true;
this.layout();
if( this._text ) {
this.setText( this._text );
delete this._text;
}
if( this._font ) {
this.setFont( this._font );
delete this._font;
}
if( typeof this._editable !== "undefined" ) {
this.setEditable( this._editable );
delete this._editable;
}
this.editor.on('focus', this.focusInHandler);
this.editor.on('blur', this.focusOutHandler);
},
focusInHandler : function(evt) {
rap.getRemoteObject(this).notify("FocusIn");
},
focusOutHandler : function(evt) {
rap.getRemoteObject(this).notify("FocusOut");
},
...
After implementation of the OperationHandler.handleNotify() method in RichTextEditor.java, the corresponding notifications about FocusIn (focus) and FocusOut (blur) events in CKEDITOR now arrive on the server-side.
This seems to be only part of the solution, though, because the RAP client does not know about the change of focus (or active widget) to the RichTextEditor widget: No corresponding focusOut event on the previously active component is generated (the caret is removed, though). I know that this is probably due to the usage of an iframe in the RichTextEditor component. When the next widget is activated, it looks like the previously active component still generated the FocusOut event.
What needs to be done in order to integrate the RichTextEditor into the focus management for both activation by mouse and keyboard? Generating Traversal events for Shift+TAB and TAB in CKEDITOR will probably be another issue.
Do I need to use some function in EventHandlerUtil instead of sending the focus events? I took a look at the mouse activation code in the client javascript code.
Is the active/focus field determined on the Javascript or Java side of RAP?
We are using the current RAP 3.1 release.
Best regards,
Gunnar
|
|
|
|
Powered by
FUDForum. Page generated in 0.03909 seconds