| Summary: | [Widgets] Label.setImage within a MouseDown event prevents a MouseUp Event | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | ArronM <arronm> |
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | albert.pikus, lshanmug, milesparker, skovatch, tamar.e.cohen |
| Version: | 3.5 | Keywords: | triaged |
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | stalebug | ||
This happens if you call Label.setText() during mouse down, too. Calling setContentView is the culprit. If I add a check to not call setContentView if the imageView/textView is already the content view, the problem goes away, but if you switch the label from text to image or vice-versa, it won't fix the problem. (In reply to comment #1) > This happens if you call Label.setText() during mouse down, too. Calling > setContentView is the culprit. If I add a check to not call setContentView if > the imageView/textView is already the content view, the problem goes away, but > if you switch the label from text to image or vice-versa, it won't fix the > problem. I just ran into this as well. This seems to me to be a bad bug as it fails silently and is really difficult to diagnose. One doesn't usually suspect a deep SWT bug in this case, so I spent a lot of time digging around in my own code to try to discover what I did wrong. Scott, can you describe a bit more about your work-around? Hi, I'm also experiencing this problem on Mac. Since I'm not changing Label's image to text or vice-versa, I just need to change an image on MouseDown event, I wonder what is the actual workaround. Scott, is there any SWT patch for this? Best regards, Albert I worked around this problem by using a Canvas instead of a label, and just drawing the image and text with the gc. (In reply to comment #4) > I worked around this problem by using a Canvas instead of a label, and just > drawing the image and text with the gc. Thank you for your suggestion, this solution works for me too. Bug triaged, visit https://wiki.eclipse.org/SWT/Devel/Triage for more information. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 Build Identifier: SWT3555 Mac Cocoa SWT, calling Label.setImage within a MouseDown event prevents a MouseUp Event from being fired Reproducible: Always Steps to Reproduce: snippet: public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new FillLayout()); final Button checkbox = new Button(shell, SWT.CHECK); checkbox.setSelection(true); checkbox.setText("SetImage in MouseDown"); final Label label = new Label(shell, SWT.NONE); label.setBackground(display.getSystemColor(SWT.COLOR_YELLOW)); label.setText("Click Me"); label.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { System.out.println("Mouse Down"); // This prevents MouseUp from firing if (checkbox.getSelection()) { label.setImage(null); } } }); label.addListener(SWT.MouseUp, new Listener() { public void handleEvent(Event event) { System.out.println("Mouse Up"); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }