Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Suppress browser shortcuts, key event bubbling
Suppress browser shortcuts, key event bubbling [message #128168] Thu, 16 April 2009 11:43 Go to next message
Lukas Dziadkowiec is currently offline Lukas DziadkowiecFriend
Messages: 12
Registered: July 2009
Junior Member
Hi,
I would like to ask about two questions.
1.
How to suppress default browser shortcuts like F5, backspace etc.
globally. I'm familiar with qooxdoo and there was not problem to filter
that directly in js. I'm able to filter this in rap also, but I would have
to add listener on every widget I have and set event.doit = false when
KEY=F5. I also tried to do something like this, to add listener on display
itself, but it doesn't work, null pointer exception.

KeyEvent.addListener(display, new KeyListener() {
public void keyPressed(KeyEvent e) {
System.out.println(e);
e.doit = false;
}

public void keyReleased(KeyEvent e) {
System.out.println(e);
e.doit = false;
}
});

2. It is possible to handle ie. KeyDown event on composite for all
children widgets without setting listener on all that widgets itself ? My
application have to handle function keys F1-F12 itself, this is why I have
to prevent F1 for help, F5 for refresh. In qooxdoo, when I set listener on
composite parent I get already event that was fired on children.
Or, is there possible to register global key events ? That way I may be
able to filter out browser shortcuts and react on my shortcuts.
Re: Suppress browser shortcuts, key event bubbling [message #128689 is a reply to message #128168] Mon, 20 April 2009 09:32 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Lukas,

Without having it tried myself, you could have a look at Display#addFilter()

Best regards, Ralf

> 1.
> How to suppress default browser shortcuts like F5, backspace etc.
> globally. I'm familiar with qooxdoo and there was not problem to filter
> that directly in js. I'm able to filter this in rap also, but I would
> have to add listener on every widget I have and set event.doit = false
> when KEY=F5. I also tried to do something like this, to add listener on
> display itself, but it doesn't work, null pointer exception.
>
> KeyEvent.addListener(display, new KeyListener() {
> public void keyPressed(KeyEvent e) {
> System.out.println(e);
> e.doit = false;
> }
>
> public void keyReleased(KeyEvent e) {
> System.out.println(e);
> e.doit = false;
> }
> });
>
> 2. It is possible to handle ie. KeyDown event on composite for all
> children widgets without setting listener on all that widgets itself ?
> My application have to handle function keys F1-F12 itself, this is why I
> have to prevent F1 for help, F5 for refresh. In qooxdoo, when I set
> listener on composite parent I get already event that was fired on
> children.
> Or, is there possible to register global key events ? That way I may be
> able to filter out browser shortcuts and react on my shortcuts.
Re: Suppress browser shortcuts, key event bubbling [message #128703 is a reply to message #128689] Mon, 20 April 2009 09:44 Go to previous messageGo to next message
Lukas Dziadkowiec is currently offline Lukas DziadkowiecFriend
Messages: 12
Registered: July 2009
Junior Member
Hi,
yes I did, but it doesn't work that way. It looks like it filters only
events that has been already registered before. I think that possibility
to filter unwanted events like F5 for browser refresh will be welcome.

BR,
Lukas.
Re: Suppress browser shortcuts, key event bubbling [message #129777 is a reply to message #128703] Thu, 23 April 2009 12:25 Go to previous messageGo to next message
Lukas Dziadkowiec is currently offline Lukas DziadkowiecFriend
Messages: 12
Registered: July 2009
Junior Member
I had a look inside org.eclipse.rap.rwt.q07 project and I found out that
is not possible to filter F1-F12 right now using just API, because this
events are ignored and just passed into browser. It is done in
org.eclipse.rwt.KeyEventHandlerPatch.js file. I done my own changes in
sync and async calls and now I can filter out F1-F12 and have this events
handled in RAP too.

async.js

intercept : function( eventType, keyCode, charCode, domEvent ) {
var result = false;
if( !this._redispatching ) {
var control = this._getTargetControl();
var hasKeyListener = this._hasKeyListener( control );
var hasTraverseListener = this._hasTraverseListener( control );
var isTraverseKey = false;
if( hasTraverseListener ) {
isTraverseKey = this._isTraverseKey( keyCode );
}

if( hasKeyListener || ( hasTraverseListener && isTraverseKey ) ) {
if( !this._isUntrustedKey( control, keyCode ) ) {
if( this._keyEventRequestRunning ||
this._bufferedEvents.length > 0 )
{
this._bufferedEvents.push( this._getEventInfo( domEvent ) );
this._cancelDomEvent( domEvent );
result = true;
} else if( this._isRelevantEvent( eventType, keyCode ) ) {
this._pendingEventInfo = this._getEventInfo( domEvent );
this._sendKeyDown( control, keyCode, charCode, domEvent );
this._cancelDomEvent( domEvent );
result = true;
}
}
} else if (( keyCode >= 112 && keyCode <= 123)) {
this._cancelDomEvent(domEvent);
}
}
return result;
},


sync.js

intercept : function( eventType, keyCode, charCode, domEvent ) {
var result = false;
var relevantEvent = this._isRelevantEvent( eventType, keyCode );
if( !org_eclipse_rap_rwt_EventUtil_suspend && relevantEvent ) {
var control = this._getTargetControl();
var hasKeyListener = this._hasKeyListener( control );
var hasTraverseListener = this._hasTraverseListener( control );
if( hasKeyListener || ( hasTraverseListener &&
this._isTraverseKey( keyCode ) ) ) {
this._pendingEvent = domEvent;
this._sendKeyDown( control, keyCode, charCode, domEvent );
result = this._isDomEventCanceled( domEvent );
if (( keyCode >= 112 && keyCode <= 123)) {
this._cancelDomEvent(domEvent);
}
} else if (( keyCode >= 112 && keyCode <= 123)) {
this._cancelDomEvent(domEvent);
}
} else {
if (( keyCode >= 112 && keyCode <= 123)) {
this._cancelDomEvent(domEvent);
}
}
return result;
},

because of IE help key hook I have to add this into
org.eclipse.rwt.KeyEventHandlerPatch

} else {
util = org.eclipse.rwt.SyncKeyEventUtil.getInstance();
document.onhelp = function() {return(false);};
window.onhelp = function() {return(false);};
}
Re: Suppress browser shortcuts, key event bubbling [message #129987 is a reply to message #129777] Fri, 24 April 2009 07:43 Go to previous message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Lukas,

RAP currently only suppresses the default action for the Esc key as
this on may also cancel a running request. It might be useful to
also prevent the default action for other keys, but that may vary
from application to application.

You should be able to do something similar as we do in
Application.js to cancel further key events. Just have a look at the
_onKeyDown function (~ line 39) and its registration (~ line 96)

HTH
Rüdiger



Lukas Dziadkowiec wrote:
> I had a look inside org.eclipse.rap.rwt.q07 project and I found out that
> is not possible to filter F1-F12 right now using just API, because this
> events are ignored and just passed into browser. It is done in
> org.eclipse.rwt.KeyEventHandlerPatch.js file. I done my own changes in
> sync and async calls and now I can filter out F1-F12 and have this
> events handled in RAP too.
>
> async.js
>
> intercept : function( eventType, keyCode, charCode, domEvent ) {
> var result = false;
> if( !this._redispatching ) {
> var control = this._getTargetControl();
> var hasKeyListener = this._hasKeyListener( control );
> var hasTraverseListener = this._hasTraverseListener( control );
> var isTraverseKey = false;
> if( hasTraverseListener ) {
> isTraverseKey = this._isTraverseKey( keyCode );
> }
> if( hasKeyListener || ( hasTraverseListener &&
> isTraverseKey ) ) {
> if( !this._isUntrustedKey( control, keyCode ) ) {
> if( this._keyEventRequestRunning ||
> this._bufferedEvents.length > 0 )
> {
> this._bufferedEvents.push( this._getEventInfo( domEvent ) );
> this._cancelDomEvent( domEvent );
> result = true;
> } else if( this._isRelevantEvent( eventType, keyCode ) ) {
> this._pendingEventInfo = this._getEventInfo( domEvent );
> this._sendKeyDown( control, keyCode, charCode, domEvent );
> this._cancelDomEvent( domEvent );
> result = true;
> }
> }
> } else if (( keyCode >= 112 && keyCode <= 123)) {
> this._cancelDomEvent(domEvent);
> }
> }
> return result;
> },
>
>
> sync.js
>
> intercept : function( eventType, keyCode, charCode, domEvent ) {
> var result = false;
> var relevantEvent = this._isRelevantEvent( eventType, keyCode );
> if( !org_eclipse_rap_rwt_EventUtil_suspend && relevantEvent ) {
> var control = this._getTargetControl();
> var hasKeyListener = this._hasKeyListener( control );
> var hasTraverseListener = this._hasTraverseListener( control );
> if( hasKeyListener || ( hasTraverseListener &&
> this._isTraverseKey( keyCode ) ) ) {
> this._pendingEvent = domEvent;
> this._sendKeyDown( control, keyCode, charCode, domEvent );
> result = this._isDomEventCanceled( domEvent );
> if (( keyCode >= 112 && keyCode <= 123)) {
> this._cancelDomEvent(domEvent);
> }
> } else if (( keyCode >= 112 && keyCode <= 123)) {
> this._cancelDomEvent(domEvent);
> }
> } else {
> if (( keyCode >= 112 && keyCode <= 123)) {
> this._cancelDomEvent(domEvent);
> }
> }
> return result;
> },
>
> because of IE help key hook I have to add this into
> org.eclipse.rwt.KeyEventHandlerPatch
>
> } else {
> util = org.eclipse.rwt.SyncKeyEventUtil.getInstance();
> document.onhelp = function() {return(false);};
> window.onhelp = function() {return(false);};
> }
>
Previous Topic:war deployment: java.lang.LinkageError?
Next Topic:Invalid thread access problem
Goto Forum:
  


Current Time: Wed Dec 01 04:34:54 GMT 2021

Powered by FUDForum. Page generated in 0.01920 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top