Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How do I know which widget lost focus when my widget gains focus?
How do I know which widget lost focus when my widget gains focus? [message #466329] Fri, 06 January 2006 16:25 Go to next message
Jim Adams is currently offline Jim AdamsFriend
Messages: 160
Registered: July 2009
Senior Member
I have a desire to know the preceding widget in the focus chain for a
selecton on one button. Since my button is part of a framework I feel
like I can't put a listener on all the widgets in the shell that
contains the button. Is there a way to put a listener on the parent
shell to track focus events?
Re: How do I know which widget lost focus when my widget gains focus? [message #466344 is a reply to message #466329] Fri, 06 January 2006 20:25 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Have a look at the SWT.Activate and SWT.Deactivate events.

Button b = new Button(shell, SWT.PUSH);
b.addListener(SWT.Activate, new Listener() {
public void handleEvent(Event e) {
System.out.println("Activate "+display.getFocusControl());
}
});

"Jim Adams" <jim.adams@sas.com> wrote in message
news:dpm5ng$ve4$1@utils.eclipse.org...
>I have a desire to know the preceding widget in the focus chain for a
>selecton on one button. Since my button is part of a framework I feel like
>I can't put a listener on all the widgets in the shell that contains the
>button. Is there a way to put a listener on the parent shell to track focus
>events?
>
Re: How do I know which widget lost focus when my widget gains focus? [message #466374 is a reply to message #466344] Mon, 09 January 2006 19:40 Go to previous messageGo to next message
Jim Adams is currently offline Jim AdamsFriend
Messages: 160
Registered: July 2009
Senior Member
How does this tell me anymore than tracking the focus events? I still
need to know which control was the previously active/focused control.

Also, where would I find any more info than what is in the help on
events like this? The text:
The activate event type (value is 26).
doesn't tell me very much.

Veronika Irvine wrote:
> Have a look at the SWT.Activate and SWT.Deactivate events.
>
> Button b = new Button(shell, SWT.PUSH);
> b.addListener(SWT.Activate, new Listener() {
> public void handleEvent(Event e) {
> System.out.println("Activate "+display.getFocusControl());
> }
> });
>
> "Jim Adams" <jim.adams@sas.com> wrote in message
> news:dpm5ng$ve4$1@utils.eclipse.org...
>
>>I have a desire to know the preceding widget in the focus chain for a
>>selecton on one button. Since my button is part of a framework I feel like
>>I can't put a listener on all the widgets in the shell that contains the
>>button. Is there a way to put a listener on the parent shell to track focus
>>events?
>>
>
>
>
Re: How do I know which widget lost focus when my widget gains focus? [message #466375 is a reply to message #466374] Mon, 09 January 2006 20:03 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Jim Adams wrote:
> How does this tell me anymore than tracking the focus events? I still
> need to know which control was the previously active/focused control.
>

That would probably be with the complementory SWT.Deactivate event,
which Veronika also mentioned :-)

Later,
PW


Re: How do I know which widget lost focus when my widget gains focus? [message #466377 is a reply to message #466375] Mon, 09 January 2006 20:48 Go to previous messageGo to next message
Jim Adams is currently offline Jim AdamsFriend
Messages: 160
Registered: July 2009
Senior Member
No, I don't think so. The problem is that when a particular widget is
actiavated it does not get told which one was deactivated, which is the
point. When I click on a button, where was the focus before I clicked?

Or am I missing something here? I still have to have a listener on EVERY
control to see if it got deactivated.

Paul Webster wrote:
> Jim Adams wrote:
>
>> How does this tell me anymore than tracking the focus events? I still
>> need to know which control was the previously active/focused control.
>>
>
> That would probably be with the complementory SWT.Deactivate event,
> which Veronika also mentioned :-)
>
> Later,
> PW
Re: How do I know which widget lost focus when my widget gains focus? [message #466381 is a reply to message #466377] Mon, 09 January 2006 22:06 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
If you look at System.out.println("Activate "+display.getFocusControl()),
the control printed out is the control that is about to lose focus. At
least it was in the scenario I tested with buttons.

"Jim Adams" <jim.adams@sas.com> wrote in message
news:dpui65$pmb$1@utils.eclipse.org...
> No, I don't think so. The problem is that when a particular widget is
> actiavated it does not get told which one was deactivated, which is the
> point. When I click on a button, where was the focus before I clicked?
>
> Or am I missing something here? I still have to have a listener on EVERY
> control to see if it got deactivated.
>
> Paul Webster wrote:
>> Jim Adams wrote:
>>
>>> How does this tell me anymore than tracking the focus events? I still
>>> need to know which control was the previously active/focused control.
>>>
>>
>> That would probably be with the complementory SWT.Deactivate event, which
>> Veronika also mentioned :-)
>>
>> Later,
>> PW
Re: How do I know which widget lost focus when my widget gains focus? [message #466428 is a reply to message #466381] Tue, 10 January 2006 14:42 Go to previous messageGo to next message
Jim Adams is currently offline Jim AdamsFriend
Messages: 160
Registered: July 2009
Senior Member
Cool! Is this behavior guarenteed on all operating systems?

Veronika Irvine wrote:
> If you look at System.out.println("Activate "+display.getFocusControl()),
> the control printed out is the control that is about to lose focus. At
> least it was in the scenario I tested with buttons.
>
> "Jim Adams" <jim.adams@sas.com> wrote in message
> news:dpui65$pmb$1@utils.eclipse.org...
>
>>No, I don't think so. The problem is that when a particular widget is
>>actiavated it does not get told which one was deactivated, which is the
>>point. When I click on a button, where was the focus before I clicked?
>>
>>Or am I missing something here? I still have to have a listener on EVERY
>>control to see if it got deactivated.
>>
>>Paul Webster wrote:
>>
>>>Jim Adams wrote:
>>>
>>>
>>>>How does this tell me anymore than tracking the focus events? I still
>>>>need to know which control was the previously active/focused control.
>>>>
>>>
>>>That would probably be with the complementory SWT.Deactivate event, which
>>>Veronika also mentioned :-)
>>>
>>>Later,
>>>PW
>
>
>
Re: How do I know which widget lost focus when my widget gains focus? [message #466570 is a reply to message #466428] Wed, 11 January 2006 18:56 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
OK. I released a new version of the Sleak plugin. Please try again. There
was a backwards compatability issue with the plugin.xml.

"Jim Adams" <jim.adams@sas.com> wrote in message
news:dq0h4s$5bh$1@utils.eclipse.org...
> Cool! Is this behavior guarenteed on all operating systems?
>
> Veronika Irvine wrote:
>> If you look at System.out.println("Activate "+display.getFocusControl()),
>> the control printed out is the control that is about to lose focus. At
>> least it was in the scenario I tested with buttons.
>>
>> "Jim Adams" <jim.adams@sas.com> wrote in message
>> news:dpui65$pmb$1@utils.eclipse.org...
>>
>>>No, I don't think so. The problem is that when a particular widget is
>>>actiavated it does not get told which one was deactivated, which is the
>>>point. When I click on a button, where was the focus before I clicked?
>>>
>>>Or am I missing something here? I still have to have a listener on EVERY
>>>control to see if it got deactivated.
>>>
>>>Paul Webster wrote:
>>>
>>>>Jim Adams wrote:
>>>>
>>>>
>>>>>How does this tell me anymore than tracking the focus events? I still
>>>>>need to know which control was the previously active/focused control.
>>>>>
>>>>
>>>>That would probably be with the complementory SWT.Deactivate event,
>>>>which Veronika also mentioned :-)
>>>>
>>>>Later,
>>>>PW
>>
>>
Re: How do I know which widget lost focus when my widget gains focus? [message #466597 is a reply to message #466570] Wed, 11 January 2006 20:40 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Sorry, posted reply to wrong question.

"Veronika Irvine" <veronika_irvine@oti.com> wrote in message
news:dq3kd4$gt1$1@utils.eclipse.org...
> OK. I released a new version of the Sleak plugin. Please try again.
> There was a backwards compatability issue with the plugin.xml.
>
> "Jim Adams" <jim.adams@sas.com> wrote in message
> news:dq0h4s$5bh$1@utils.eclipse.org...
>> Cool! Is this behavior guarenteed on all operating systems?
>>
>> Veronika Irvine wrote:
>>> If you look at System.out.println("Activate
>>> "+display.getFocusControl()), the control printed out is the control
>>> that is about to lose focus. At least it was in the scenario I tested
>>> with buttons.
>>>
>>> "Jim Adams" <jim.adams@sas.com> wrote in message
>>> news:dpui65$pmb$1@utils.eclipse.org...
>>>
>>>>No, I don't think so. The problem is that when a particular widget is
>>>>actiavated it does not get told which one was deactivated, which is the
>>>>point. When I click on a button, where was the focus before I clicked?
>>>>
>>>>Or am I missing something here? I still have to have a listener on EVERY
>>>>control to see if it got deactivated.
>>>>
>>>>Paul Webster wrote:
>>>>
>>>>>Jim Adams wrote:
>>>>>
>>>>>
>>>>>>How does this tell me anymore than tracking the focus events? I still
>>>>>>need to know which control was the previously active/focused control.
>>>>>>
>>>>>
>>>>>That would probably be with the complementory SWT.Deactivate event,
>>>>>which Veronika also mentioned :-)
>>>>>
>>>>>Later,
>>>>>PW
>>>
>>>
>
Previous Topic:how to add SWT Widgets in Table Cell
Next Topic:Tree on Linux
Goto Forum:
  


Current Time: Thu Dec 26 19:58:27 GMT 2024

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

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

Back to the top