Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 387338 - Cocoa: [New SWT style required]single click only bring a window to the top but do not take effective for the click object
Summary: Cocoa: [New SWT style required]single click only bring a window to the top bu...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7.2   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 4.3 M2   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-15 22:33 EDT by ChunYan Zhang CLA
Modified: 2012-09-28 17:43 EDT (History)
5 users (show)

See Also:


Attachments
patch for R3_7_maintenance branch (7.26 KB, patch)
2012-08-20 15:12 EDT, Silenio Quarti CLA
no flags Details | Diff
new patch for R3_7_maintenance (8.81 KB, patch)
2012-09-05 14:09 EDT, Silenio Quarti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ChunYan Zhang CLA 2012-08-15 22:33:23 EDT
There is a different system behaviors against Mac Cocoa and Mac Carbon/Windows/Linux. IF there are two windows on the screen, window 1 has focus(on top), window 2 not, click a control on window 2:
1. On Mac Carbon/Windows/Linux, window 2 will get focus(move to top) and the clicked control will take effective.  It means single click do two things: (1) Windows got focus (2)Control is clicked

2. On Mac Cocoa, partial controls has same behaviors, but most of other controls difference. Single click only make window get focus, if we want to the control work, another click is necessary. 

In the SWT's Control class, if the style is STW.ON_TOP, the acceptsFirstMouse will return true, then the control will be focused only a single click. But STW.ON_TOP will be used in other scenario, can we provide a new style to control whether accept the first mouse?


boolean acceptsFirstMouse (int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
	Shell shell = getShell ();
	if ((shell.style & SWT.ON_TOP) != 0) return true;
	return super.acceptsFirstMouse (id, sel, theEvent);
}
Comment 1 Silenio Quarti CLA 2012-08-20 15:04:22 EDT
SWT for carbon only overwrote this Mac behavior for four widgets (Table, Tree, List and Browser).  Other widgets do not accept the first click (i.e Button, ToolBar, etc).

I was considering adding acceptsFirstMouse to those widgets only (to be consistent with carbon) and return true, but that does not seem to fix the problem for those widgets. Does it fix the problem for you?
Comment 2 Silenio Quarti CLA 2012-08-20 15:12:32 EDT
Created attachment 220075 [details]
patch for R3_7_maintenance branch

This patch fix the problem for Table/Tree/List. Browser already works as mentioned.  We are not changing the behaviour for other widgets.

Overwriting acceptsFirstMouse for Table/Tree/List is not enough. We need to overwrite needsPanelToBecomeKey and acceptsFirstResponder.

Please try this patch out. It works for me, but I have done only minimal testing.
Comment 3 Silenio Quarti CLA 2012-09-05 14:09:47 EDT
Created attachment 220743 [details]
new patch for R3_7_maintenance

I missed one case. Custom widgets also accepts the first click on SWT for carbon.

Please try this patch out.
Comment 4 ChunYan Zhang CLA 2012-09-05 22:35:10 EDT
Tha new patch works now. Thanks very much.

(In reply to comment #3)
> Created attachment 220743 [details]
> new patch for R3_7_maintenance
> 
> I missed one case. Custom widgets also accepts the first click on SWT for
> carbon.
> 
> Please try this patch out.
Comment 5 Silenio Quarti CLA 2012-09-06 09:47:29 EDT
Thanks for verifying the fix. Released to master (4.3).

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=904726b3be2bccd3138b183ec66e6878016a6ed0
Comment 6 Carolyn MacLeod CLA 2012-09-28 17:43:33 EDT
The fix for this caused bug 390734, which is now fixed.