Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » FocusGained Events from custom Buttons
FocusGained Events from custom Buttons [message #68876] Fri, 04 January 2008 09:21 Go to next message
Eclipse UserFriend
Dear all,
I am trying to understand how the Focus Events work in RAP but it seems that
I am not quite sure how to solve my problem.

A standard button in RAP is firing a FocusGainedEvent before the SelectionEvent will
be fired.

However my custom Button does not although I need the same behaviour.
I've figured out that the FocusGainedEvent from RAP Buttons will be fired before
the lifecycle process is entering the readData method of e.g. PushButtonDelegateLCA.
Before that the readData method of DisplayLCA is fired and here with readFocusControl the
FocusGainedEvent will be fired.

How can I manage that my custom Widget will be recognized to gain Focus, too?
I've seen that there is a writeFocusListener method in the ControlLCAUtil class.
But I am not sure if I am on the right path as I do not completely understand what
this method is for.

Thanks

Oliver
Re: FocusGained Events from custom Buttons [message #68918 is a reply to message #68876] Fri, 04 January 2008 11:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Hi Oliver,

as long as your client-side widget is qooxdoo-based ('inherits' from
qx.ui.core.Widget) all you need to do is to call
ControlLCAUtil#writeChanges which in turn calls #writeFocusListener.
This method takes care that client-side focus events are sent to the
server-side when necessary.

HTH
Rüdiger


Poncho wrote:
> Dear all,
> I am trying to understand how the Focus Events work in RAP but it seems
> that
> I am not quite sure how to solve my problem.
>
> A standard button in RAP is firing a FocusGainedEvent before the
> SelectionEvent will
> be fired.
>
> However my custom Button does not although I need the same behaviour.
> I've figured out that the FocusGainedEvent from RAP Buttons will be
> fired before
> the lifecycle process is entering the readData method of e.g.
> PushButtonDelegateLCA.
> Before that the readData method of DisplayLCA is fired and here with
> readFocusControl the
> FocusGainedEvent will be fired.
>
> How can I manage that my custom Widget will be recognized to gain Focus,
> too?
> I've seen that there is a writeFocusListener method in the
> ControlLCAUtil class.
> But I am not sure if I am on the right path as I do not completely
> understand what
> this method is for.
>
> Thanks
>
> Oliver
Re: FocusGained Events from custom Buttons [message #69044 is a reply to message #68918] Mon, 07 January 2008 03:23 Go to previous messageGo to next message
Eclipse UserFriend
Hi Rüdiger,
thanks for the hint, but I've tried so before but unfortunately it
didn't work. The widgetSelected method will still be called before
entering the focusLost method.
I checked briefly the qooxdoo code (as it is not mine, but from Istvan ;-) )
and it seems that the class is derived from qx.ui.layout.CanvasLayout which
in turn is dervived from qx.ui.core.Widget via qx.ui.core.Parent.
I will check with Istvan if there is something in the qx code that changes
the regular order.

Regards

Oliver

Rüdiger Herrmann schrieb:
> Hi Oliver,
>
> as long as your client-side widget is qooxdoo-based ('inherits' from
> qx.ui.core.Widget) all you need to do is to call
> ControlLCAUtil#writeChanges which in turn calls #writeFocusListener.
> This method takes care that client-side focus events are sent to the
> server-side when necessary.
>
> HTH
> Rüdiger
>
>
> Poncho wrote:
>> Dear all,
>> I am trying to understand how the Focus Events work in RAP but it
>> seems that
>> I am not quite sure how to solve my problem.
>>
>> A standard button in RAP is firing a FocusGainedEvent before the
>> SelectionEvent will
>> be fired.
>>
>> However my custom Button does not although I need the same behaviour.
>> I've figured out that the FocusGainedEvent from RAP Buttons will be
>> fired before
>> the lifecycle process is entering the readData method of e.g.
>> PushButtonDelegateLCA.
>> Before that the readData method of DisplayLCA is fired and here with
>> readFocusControl the
>> FocusGainedEvent will be fired.
>>
>> How can I manage that my custom Widget will be recognized to gain
>> Focus, too?
>> I've seen that there is a writeFocusListener method in the
>> ControlLCAUtil class.
>> But I am not sure if I am on the right path as I do not completely
>> understand what
>> this method is for.
>>
>> Thanks
>>
>> Oliver
Re: FocusGained Events from custom Buttons [message #69247 is a reply to message #68918] Tue, 08 January 2008 10:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi Rüdiger,
I am not sure if the problem I've mentioned is really focusLost/focusGained based.
We've tried to check a little deeper and we've found out that there is
a function in Shell.js which is sending a parameter w1.focusControl=#WIDGET_ID
Allthough we're sending focusGained/focusLost event BEFORE the SelectionEvent they still will
be handled AFTER the SelectionEvent in Java.
In our custom widgets the parameter w1.focusControl is null
In standard RAP widgets it is always correctly set.
How can I set this param correctly??
Do I have to call setTabIndex() in the custom qx class?
Or is it another mechanism???

Regards
Oliver

Rüdiger Herrmann schrieb:
> Hi Oliver,
>
> as long as your client-side widget is qooxdoo-based ('inherits' from
> qx.ui.core.Widget) all you need to do is to call
> ControlLCAUtil#writeChanges which in turn calls #writeFocusListener.
> This method takes care that client-side focus events are sent to the
> server-side when necessary.
>
> HTH
> Rüdiger
>
>
> Poncho wrote:
>> Dear all,
>> I am trying to understand how the Focus Events work in RAP but it
>> seems that
>> I am not quite sure how to solve my problem.
>>
>> A standard button in RAP is firing a FocusGainedEvent before the
>> SelectionEvent will
>> be fired.
>>
>> However my custom Button does not although I need the same behaviour.
>> I've figured out that the FocusGainedEvent from RAP Buttons will be
>> fired before
>> the lifecycle process is entering the readData method of e.g.
>> PushButtonDelegateLCA.
>> Before that the readData method of DisplayLCA is fired and here with
>> readFocusControl the
>> FocusGainedEvent will be fired.
>>
>> How can I manage that my custom Widget will be recognized to gain
>> Focus, too?
>> I've seen that there is a writeFocusListener method in the
>> ControlLCAUtil class.
>> But I am not sure if I am on the right path as I do not completely
>> understand what
>> this method is for.
>>
>> Thanks
>>
>> Oliver
Re: FocusGained Events from custom Buttons [message #69330 is a reply to message #69247] Wed, 09 January 2008 03:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Hi Oliver,

I don't quite understand what you mean by "we're sending
focusGained/focusLost event". Calling ControlLCAUtil#writeChanges() in
your LCAs' renderChanges() method should be sufficient to get focus events.
If the w1.focusControl parameter is null, then no focus events should occur.
setTabIndex controls the order in which widgets are traversed through
when using the TAB key. This is also handled in
ControlLCAUtil#writeChanges().
Currently, the event order is hard-coded, focus-events are fired before
selection-events. I would assume that in your case the events are fired
in different requests. Can you confirm this?
Could you maybe post the relevant code? That would help to track down
the problem.

Cheers,
Rüdiger

Poncho wrote:
> Hi Rüdiger,
> I am not sure if the problem I've mentioned is really
> focusLost/focusGained based.
> We've tried to check a little deeper and we've found out that there is
> a function in Shell.js which is sending a parameter
> w1.focusControl=#WIDGET_ID
> Allthough we're sending focusGained/focusLost event BEFORE the
> SelectionEvent they still will
> be handled AFTER the SelectionEvent in Java.
> In our custom widgets the parameter w1.focusControl is null
> In standard RAP widgets it is always correctly set.
> How can I set this param correctly??
> Do I have to call setTabIndex() in the custom qx class?
> Or is it another mechanism???
>
> Regards
> Oliver
>
> Rüdiger Herrmann schrieb:
>> Hi Oliver,
>>
>> as long as your client-side widget is qooxdoo-based ('inherits' from
>> qx.ui.core.Widget) all you need to do is to call
>> ControlLCAUtil#writeChanges which in turn calls #writeFocusListener.
>> This method takes care that client-side focus events are sent to the
>> server-side when necessary.
>>
>> HTH
>> Rüdiger
>>
>>
>> Poncho wrote:
>>> Dear all,
>>> I am trying to understand how the Focus Events work in RAP but it
>>> seems that
>>> I am not quite sure how to solve my problem.
>>>
>>> A standard button in RAP is firing a FocusGainedEvent before the
>>> SelectionEvent will
>>> be fired.
>>>
>>> However my custom Button does not although I need the same behaviour.
>>> I've figured out that the FocusGainedEvent from RAP Buttons will be
>>> fired before
>>> the lifecycle process is entering the readData method of e.g.
>>> PushButtonDelegateLCA.
>>> Before that the readData method of DisplayLCA is fired and here with
>>> readFocusControl the
>>> FocusGainedEvent will be fired.
>>>
>>> How can I manage that my custom Widget will be recognized to gain
>>> Focus, too?
>>> I've seen that there is a writeFocusListener method in the
>>> ControlLCAUtil class.
>>> But I am not sure if I am on the right path as I do not completely
>>> understand what
>>> this method is for.
>>>
>>> Thanks
>>>
>>> Oliver
Re: FocusGained Events from custom Buttons [message #69350 is a reply to message #69330] Wed, 09 January 2008 04:48 Go to previous message
Eclipse UserFriend
Hi Rüdiger,
yes that's right. The events come in two different requests.
By saying "sending focusGained/focusLost event" I wanted to point out, that the problem
is not due to missing parameter focusLost/focusGained but to something else.
I think the relevant code would not explain the problem *) so I will post you first
the parameters of the request:

org.eclipse.swt.events.focusLost=w627
org.eclipse.swt.events.widgetSelected=w591
requestCounter=7
uiRoot=w1
w1.focusControl=null
w591.selection=true
w627.selectionStart=10
w627.text=10.10.2007
w7.activeControl=w591

In DisplayLCA#readFocusControl the focusLost/focusGained event is triggered
by checking the widget ID in parameter w1.focusControl. However this ID was null
for all of our custom widgets.

I thought of setting the setTabIndex in qx because of the following description (from qx-api):
"tabIndex: Set this to a positive value makes the widget able to get the focus."
So I though, that this has to be called in order to get a focus event.

But I have a workaround that suits us - at least at the moment.
To have a correct sequence I call setFocused(true) in the qx event onmousedown in our custom
buttons. This leads to the following parameters:

org.eclipse.swt.events.focusLost=w627
org.eclipse.swt.events.widgetSelected=w591
requestCounter=7
uiRoot=w1
w1.focusControl=w591
w591.selection=true
w627.selectionStart=10
w627.text=10.10.2007
w7.activeControl=w591

Now the focusLost event will be triggered correctly.

Thanks & Regards

Oliver



*)
- The custom widget's readData:
public void readData(Widget widget) {
final AbstractButton button = (AbstractButton) widget;
ControlLCAUtil.processSelection(button, null, false);

}

- Another readData of the custom widget I have tested but with no success:
public void readData(Widget widget) {
final AbstractButton button = (AbstractButton) widget;

final String evSelId = JSConst.EVENT_WIDGET_SELECTED;
final String evDefSelId = JSConst.EVENT_WIDGET_DEFAULT_SELECTED;

if( WidgetLCAUtil.wasEventSent( widget, evSelId )
|| WidgetLCAUtil.wasEventSent( widget, evDefSelId ) ) {
FocusEvent event = new FocusEvent(button,FocusEvent.FOCUS_LOST);
event.processEvent();
ControlLCAUtil.processSelection(button, null, false);
}
}

- The original qx code of the class AbstractButton.js
/**
* TODOC
*
* @type member
* @return {void}
*/
_onmousedown : function() {
this.addState("pressed");
this.renderButton();
},

- The workaround
/**
* TODOC
*
* @type member
* @return {void}
*/
_onmousedown : function() {
this.setFocused(true);
this.addState("pressed");
this.renderButton();
},


Rüdiger Herrmann schrieb:
> Hi Oliver,
>
> I don't quite understand what you mean by "we're sending
> focusGained/focusLost event". Calling ControlLCAUtil#writeChanges() in
> your LCAs' renderChanges() method should be sufficient to get focus events.
> If the w1.focusControl parameter is null, then no focus events should
> occur.
> setTabIndex controls the order in which widgets are traversed through
> when using the TAB key. This is also handled in
> ControlLCAUtil#writeChanges().
> Currently, the event order is hard-coded, focus-events are fired before
> selection-events. I would assume that in your case the events are fired
> in different requests. Can you confirm this?
> Could you maybe post the relevant code? That would help to track down
> the problem.
>
> Cheers,
> Rüdiger
>
> Poncho wrote:
>> Hi Rüdiger,
>> I am not sure if the problem I've mentioned is really
>> focusLost/focusGained based.
>> We've tried to check a little deeper and we've found out that there is
>> a function in Shell.js which is sending a parameter
>> w1.focusControl=#WIDGET_ID
>> Allthough we're sending focusGained/focusLost event BEFORE the
>> SelectionEvent they still will
>> be handled AFTER the SelectionEvent in Java.
>> In our custom widgets the parameter w1.focusControl is null
>> In standard RAP widgets it is always correctly set.
>> How can I set this param correctly??
>> Do I have to call setTabIndex() in the custom qx class?
>> Or is it another mechanism???
>>
>> Regards
>> Oliver
>>
>> Rüdiger Herrmann schrieb:
>>> Hi Oliver,
>>>
>>> as long as your client-side widget is qooxdoo-based ('inherits' from
>>> qx.ui.core.Widget) all you need to do is to call
>>> ControlLCAUtil#writeChanges which in turn calls #writeFocusListener.
>>> This method takes care that client-side focus events are sent to the
>>> server-side when necessary.
>>>
>>> HTH
>>> Rüdiger
>>>
>>>
>>> Poncho wrote:
>>>> Dear all,
>>>> I am trying to understand how the Focus Events work in RAP but it
>>>> seems that
>>>> I am not quite sure how to solve my problem.
>>>>
>>>> A standard button in RAP is firing a FocusGainedEvent before the
>>>> SelectionEvent will
>>>> be fired.
>>>>
>>>> However my custom Button does not although I need the same behaviour.
>>>> I've figured out that the FocusGainedEvent from RAP Buttons will be
>>>> fired before
>>>> the lifecycle process is entering the readData method of e.g.
>>>> PushButtonDelegateLCA.
>>>> Before that the readData method of DisplayLCA is fired and here with
>>>> readFocusControl the
>>>> FocusGainedEvent will be fired.
>>>>
>>>> How can I manage that my custom Widget will be recognized to gain
>>>> Focus, too?
>>>> I've seen that there is a writeFocusListener method in the
>>>> ControlLCAUtil class.
>>>> But I am not sure if I am on the right path as I do not completely
>>>> understand what
>>>> this method is for.
>>>>
>>>> Thanks
>>>>
>>>> Oliver
Previous Topic:how are sessions managed / security
Next Topic:Classpath problem
Goto Forum:
  


Current Time: Fri Jun 06 12:27:41 EDT 2025

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

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

Back to the top