Bug 388574 - [Mac OS X 10.8] Text control loses focus upon its movement
Summary: [Mac OS X 10.8] Text control loses focus upon its movement
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.2   Edit
Hardware: Macintosh Mac OS X
: P3 major with 4 votes (vote)
Target Milestone: 4.2.2   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 386639 390800
  Show dependency tree
 
Reported: 2012-08-31 14:36 EDT by Alexander Mitin CLA
Modified: 2013-01-17 14:35 EST (History)
9 users (show)

See Also:
Silenio_Quarti: review+


Attachments
Test case reproducing the issue. (1.85 KB, application/octet-stream)
2012-08-31 14:36 EDT, Alexander Mitin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Mitin CLA 2012-08-31 14:36:50 EDT
Created attachment 220621 [details]
Test case reproducing the issue.

Text control loses focus upon its movement in Mac OS X 10.8 if created and displayed after Shell is opened.

Text text1 = new Text(shell, SWT.BORDER);
text1.setFocus();
text1.setBounds(10, 10, 64, 16);

Test case is attached.

Run the test case and click on "Click here!" label. See the sysout.
Expected: 
    "Text1: focus gained."
Actual:
    "Text1: focus gained.
     Text1: focus lost.
     Text1: focus gained."

Works as expected on Mac OS X 10.6.7.
Comment 1 Markus Keller CLA 2012-08-31 16:34:12 EDT
I can reproduce the bad FocusOut event with the snippet on 10.8:

at test.TestFocus$2.focusLost(TestFocus.java:74)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:143)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4143)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1462)
at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:3295)
at org.eclipse.swt.widgets.Display.checkFocus(Display.java:650)
at org.eclipse.swt.widgets.Shell.makeFirstResponder(Shell.java:1260)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5613)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:221)
at org.eclipse.swt.widgets.Widget.textDidEndEditing(Widget.java:1955)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5581)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Widget.callSuperBoolean(Widget.java:288)
at org.eclipse.swt.widgets.Widget.makeFirstResponder(Widget.java:1166)
at org.eclipse.swt.widgets.Shell.makeFirstResponder(Shell.java:1259)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5613)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Widget.setFrameSize(Widget.java:1663)
at org.eclipse.swt.widgets.Control.setFrameSize(Control.java:3800)
at org.eclipse.swt.widgets.Text.setFrameSize(Text.java:1796)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5495)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSView.setFrame(NSView.java:267)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:3536)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:3525)
at test.TestFocus.createText(TestFocus.java:82)
at test.TestFocus$1.mouseDown(TestFocus.java:58)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:192)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4143)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1271)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3989)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3628)
at test.TestFocus.open(TestFocus.java:40)
at test.TestFocus.main(TestFocus.java:25)
Comment 2 Tor Norbye CLA 2012-10-03 15:47:41 EDT
This bug is basically blocking the Android plugin (the layout editor) as well; the property sheet won't work for text properties (which are probably the most important ones).
Comment 3 Lars Vogel CLA 2012-10-04 15:36:49 EDT
Is this the same as Bug 390924? 

@Tor: Could you try the patch we applied for 4.3.2?
Comment 4 Tor Norbye CLA 2012-10-04 16:01:36 EDT
I'll try with the latest nightly build:
http://download.eclipse.org/eclipse/downloads/drops4/N20121003-2000/
That contains the fix, right? If not, is there somewhere I can grab prebuilt binaries which include the fix?
Comment 5 Lars Vogel CLA 2012-10-04 16:14:37 EDT
I think the latest build should contain that. Not sure though. 

To test you can:
1.) 
git clone http://anonymous@git.eclipse.org/gitroot/platform/eclipse.platform.ui.git

2.) Import the org.eclipse.ui.ide project into Eclipse and apply the patch on it
3.) Start a runtime Eclipse (right mouse click on org.eclipse.ui.ide -> Run as -> Eclipse Application)

Fortunately ;-) I don't have a Mac so I can't test.
Comment 6 Tor Norbye CLA 2012-10-04 16:36:12 EDT
It's not fixed in the nightly build I downloaded. I'll try your patch approach now in case it's just a matter of the fix not being included in that nightly yet.
Comment 7 Tor Norbye CLA 2012-10-04 17:01:26 EDT
Actually, it looks like that patch is for the Eclipse UI. That seems like a different bug, since this one is reproducible with a simple SWT example (the original test case attached to this bug).
Comment 9 Tor Norbye CLA 2012-10-04 17:42:52 EDT
Sweet, thank you!!
Comment 10 Tor Norbye CLA 2012-10-10 14:09:38 EDT
I can confirm that this fix works for our scenario in the Android plugin as well (tested with a 4.3 nightly).

Any plans to backport it to 4.2 maintenance releases?
Comment 11 Silenio Quarti CLA 2012-10-10 15:38:17 EDT
It requires more testing before we can back port it. I will reopen and target it for 4.2.2 so that we do not forget.
Comment 12 Bogdan Gheorghe CLA 2013-01-15 12:45:53 EST
Backported to 4_2_maintenance and 3_8_maintenance