-
Notifications
You must be signed in to change notification settings - Fork 187
[GTK] Don't invalidate style context when setting background color #2702 #2786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+65
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...sts.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Issue2702_DoubleClickBehavior.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2025 Patrick Ziegler and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * Patrick Ziegler - initial API and implementation | ||
| *******************************************************************************/ | ||
| package org.eclipse.swt.tests.gtk.snippets; | ||
|
|
||
| import org.eclipse.swt.*; | ||
| import org.eclipse.swt.graphics.*; | ||
| import org.eclipse.swt.layout.*; | ||
| import org.eclipse.swt.widgets.*; | ||
|
|
||
| /** | ||
| * This snippet demonstrates a missed selection event when updating the | ||
| * background color within an SWT.Activate event. To reproduce, alternative | ||
| * between the table and the tree. On each click, the clicked tree/table item | ||
| * should be selected. | ||
| * | ||
| * @see <a href="https://github.com/eclipse-platform/eclipse.platform.swt/issues/2702">Issue 2702</a> | ||
| */ | ||
| public class Issue2702_DoubleClickBehavior { | ||
| private static Color ACTIVE = new Color(255, 255, 255); | ||
| private static Color INACTIVE = new Color(248, 248, 248); | ||
|
|
||
| public static void main(String[] args) { | ||
| Shell shell = new Shell(); | ||
| shell.setLayout(new GridLayout(2, true)); | ||
| shell.setSize(400, 200); | ||
|
|
||
| Tree tree = new Tree(shell, SWT.FULL_SELECTION); | ||
| tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | ||
| TreeItem treeItem1 = new TreeItem(tree, SWT.NONE); | ||
| treeItem1.setText("Tree Item 1"); | ||
| TreeItem treeItem2 = new TreeItem(tree, SWT.NONE); | ||
| treeItem2.setText("Tree Item 2"); | ||
| tree.addListener(SWT.Activate, event -> tree.setBackground(ACTIVE)); | ||
| tree.addListener(SWT.Deactivate, event -> tree.setBackground(INACTIVE)); | ||
|
|
||
| Table table = new Table(shell, SWT.FULL_SELECTION); | ||
| table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | ||
| TableItem tableItem1 = new TableItem(table, SWT.NONE); | ||
| tableItem1.setText("Table Item 1"); | ||
| TableItem tableItem2 = new TableItem(table, SWT.NONE); | ||
| tableItem2.setText("Table Item 2"); | ||
| table.addListener(SWT.Activate, event -> table.setBackground(ACTIVE)); | ||
| table.addListener(SWT.Deactivate, event -> table.setBackground(INACTIVE)); | ||
|
|
||
| shell.open(); | ||
|
|
||
| Display display = shell.getDisplay(); | ||
| while (!shell.isDisposed()) { | ||
| if (!display.readAndDispatch()) { | ||
| display.sleep(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.