Event handler not called (button) [message #809466] |
Tue, 28 February 2012 17:51  |
Eclipse User |
|
|
|
When I start a clean application and create an MPart from an MPartDescriptor and show it, it automatically receives the focus. When I click on a button in the MPart for the first time, the event is fired and the event handler is called. This is the expected behaviour.
When I close this application without deleting the MPart and start it again, the MPart is immediately created from the model state that has been saved before. This time MPart does not immediately receive the focus. This is o.k., since there might be more than one MPart. If I now click on the same button again for the first time, the MPart receives the focus (o.k.), but the event is not fired, i.e. the handler of the button is not called. It is only called, when I click for the second time on the button.
To summarize: The handler of a button is only called, when the corresponding MPart had the focus before the button is clicked. Otherwise one has to click the button twice, to get the handler called once, which is completely unexpected.
Have I missed something, or is this a bug in e4 (Version: 4.2.0 / Build id: I20120209-1230)?
|
|
|
|
|
|
|
Re: Event handler not called (button) [message #812246 is a reply to message #812141] |
Sat, 03 March 2012 08:25   |
Eclipse User |
|
|
|
Ok, the hint with a missing setFocus was basically correct. The following line of code fixes the problem:
However, this line of code has to be added as last line of the method buildUI().
When the MPart is created in the handler using the code
@Execute
public void execute(EPartService partService) {
MPart part = partService.findPart(LogView.ID);
if (part == null) {
part = partService.createPart(LogView.ID);
}
if (part != null) {
part.setLabel("DBLogView");
part.setTooltip("Tooltip");
partService.showPart(part, PartState.ACTIVATE);
}
}
then partService.showPart(...) ensures, that the @Focus method is called immediately. Even more, everything works properly without explicitly calling composite.setFocus() at all. I.e. it must neither be called in buildUI() nor in the @Focus method.
If the UI is built after the application restarts, the Part is shown but the @Focus method is not called immediately. Although the Part is completely visible, the @Focus method is only called when I first click into the part. However, for the part to work properly in this case, composite.setFocus() has to be called explicitly in buildUI().
If, on the other hand, composite.setFocus() is called in buildUI(), then in certain cases this method is called twice.
This behaviour should be a bug.
|
|
|
|
Re: Event handler not called (button) [message #814412 is a reply to message #813698] |
Tue, 06 March 2012 07:17  |
Eclipse User |
|
|
|
Hi Lars,
thanks, I will try when I am at home. But I think the underlying problem is, that the "restarted" part does not get the focus in time, or, to be more precise, I suspect that the following bug is the cause of my trouble. After I added my comment it was rescheduled from 4.1.2 to 4.2, so there seems to be hope that it might be fixed soon....
|
|
|
Powered by
FUDForum. Page generated in 0.09561 seconds