Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Setting focus to another part programmatically
Setting focus to another part programmatically [message #1718292] Tue, 22 December 2015 07:55 Go to next message
Mihael Schmidt is currently offline Mihael SchmidtFriend
Messages: 81
Registered: August 2010
Member
I am trying to move the focus from one part to another part. I tried:

partService.activate(part, true);

My part has the following code:

@Focus
public void onFocus() {
getViewer().getControl().setFocus();
}

But this is never called. What am I doing wrong?

Thanx in advance

Mihael
Re: Setting focus to another part programmatically [message #1718350 is a reply to message #1718292] Tue, 22 December 2015 18:08 Go to previous messageGo to next message
Eclipse UserFriend
Try enabling the DI tracing options (launch configuration dialog > Tracing > org.eclipse.e4.core.di for debug/injector) and see if there's an issue when invoking the method.

Otherwise please post an example demonstrating the problem. You're simply not providing sufficient context to narrow down the problem.

Brian.
Re: Setting focus to another part programmatically [message #1718389 is a reply to message #1718350] Wed, 23 December 2015 09:14 Go to previous messageGo to next message
Mihael Schmidt is currently offline Mihael SchmidtFriend
Messages: 81
Registered: August 2010
Member
Sorry for not being able to give enough info. I am a bit under pressure for making a release.

I have done some more testing and can confirm that it does not happen on all platforms. On windows (win 7 64bit) it works. On linux (debian 7 64 bit openbox) it works partially.

If I am using a double click action from one part to focus another part it doesn't work on my linux desktop. If I use a popup menu entry from one part to activate and focus another part it also works on linux.

I can also confirm that the method which is annotated with @Focus is called every time.

I hope it helps.

Mihael
Re: Setting focus to another part programmatically [message #1718393 is a reply to message #1718389] Wed, 23 December 2015 10:06 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
have you tried simply delaying the focus transferal by scheduling a
asyncExec? I think the problem on Linux is that everything involved is
inheritly async and eg mouse-events are delivered not in the same
dispatch (although already scheduled on the event-queue), an asyncExec
would make sure that all the focus transfer is after all other events.

Tom

On 23.12.15 10:14, Mihael Schmidt wrote:
> Sorry for not being able to give enough info. I am a bit under pressure
> for making a release.
>
> I have done some more testing and can confirm that it does not happen on
> all platforms. On windows (win 7 64bit) it works. On linux (debian 7 64
> bit openbox) it works partially.
>
> If I am using a double click action from one part to focus another part
> it doesn't work on my linux desktop. If I use a popup menu entry from
> one part to activate and focus another part it also works on linux.
>
> I can also confirm that the method which is annotated with @Focus is
> called every time.
>
> I hope it helps.
>
> Mihael
Re: Setting focus to another part programmatically [message #1718396 is a reply to message #1718393] Wed, 23 December 2015 11:05 Go to previous message
Mihael Schmidt is currently offline Mihael SchmidtFriend
Messages: 81
Registered: August 2010
Member
Thomas Schindl wrote on Wed, 23 December 2015 11:06
have you tried simply delaying the focus transferal by scheduling a
asyncExec? I think the problem on Linux is that everything involved is
inheritly async and eg mouse-events are delivered not in the same
dispatch (although already scheduled on the event-queue), an asyncExec
would make sure that all the focus transfer is after all other events.


Wow. I am impressed by your deep knowledge. You hit the nail on the head. Wrapping it up into an asyncExec worked.

Thanx very much.

Mihael
Previous Topic:CSS is not working after migrated to RCP 4
Next Topic:Multiple command handler enablement states.
Goto Forum:
  


Current Time: Thu Mar 28 23:49:21 GMT 2024

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

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

Back to the top