eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
114 stars 130 forks source link

Scrolling Issue with ScrolledFormText #532

Open TorstenU opened 1 year ago

TorstenU commented 1 year ago

Describe the bug If a ScrolledFormText is scrolled vertically and text is selected using the mouse, the selection foreground and background colors are not applied as expected. The selection itself is correct only the visual feedback seems to be wrong.

To Reproduce `import org.eclipse.swt.; import org.eclipse.swt.graphics.; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; import org.eclipse.ui.forms.widgets.ScrolledFormText;

import com.sqlag.tc.manager.util.AbstractPart;

public class Snippet26 {

public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); shell.setText("Snippet 26");

shell.setLayout( new GridLayout( 1, false ) );

ScrolledFormText formText = new ScrolledFormText( shell, SWT.H_SCROLL | SWT.V_SCROLL, true ); formText.setText( text );

// get preferred size of the content Point size = formText.getFormText().computeSize( SWT.DEFAULT, SWT.DEFAULT );

// limit size of scrolled control to max 600x500 GridData gdata = new GridData( SWT.FILL, SWT.FILL, true, true ); gdata.widthHint = Math.min( size.x, 600 ); gdata.heightHint = Math.min( size.y, 500 ); formText.setLayoutData( gdata );

shell.pack (); shell.open (); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }

static String text = "

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

Das ist ein langer Text

"; }`

Expected behavior The selection colors must be applied at the correct location (as if they are if not scrolled).

Screenshots screen

Environment:

  1. Select the platform(s) on which the behavior is seen:

      • [ ] All OS
      • [x] Windows
      • [x] Linux
      • [ ] macOS
  2. Additional OS info (e.g. OS version, Linux Desktop, etc) Windows 10, Linux Ubuntu 22.04

  3. JRE/JDK version Eclipse Adoptium 11

Version since Eclipse 2020-06

elsazac commented 1 year ago

@TorstenU

I have tried your snippet on Mac. Inspite of rectifying some issues related to the snippet, I am still not able to run the snippet. Can you share a snippet without errors which reproduces the issue.

TorstenU commented 1 year ago

Sorry for buggy code, the web formatting has dropped some characters. Attached You find an Eclipse Project created on 2023-03-R (win) with a simple RCP with one view. Hope this helps. issue532.zip

deepika-u commented 1 year ago

@TorstenU Can you give us the indetail instructions on how to run this please.

TorstenU commented 1 year ago

Hi @deepika-u,

with best regards Torsten

deepika-u commented 1 year ago

@TorstenU I am checking the same on windows 11. Thanks for the quick detailed steps. When right click on plugin.xml and run it as "Eclipse Application", I am getting the below popup => image

(Irrespective of 1st or 2nd selection)i selected the 1st one and say "Continue", I get the below console output and one new window opens up

  1. console output shows :

Framework arguments: -application Issue532.application Command-line arguments: -application Issue532.application -data C:\e\swt/../runtime-Issue532.application -dev file:C:/e/swt/.metadata/.plugins/org.eclipse.pde.core/Issue532.application/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog

!ENTRY org.eclipse.swt.tools 4 0 2023-04-05 17:36:41.536 !MESSAGE FrameworkEvent ERROR !STACK 0 org.osgi.framework.BundleException: Could not resolve module: org.eclipse.swt.tools [72] Unresolved requirement: Require-Bundle: org.eclipse.jdt.core; bundle-version="3.4.0"

at org.eclipse.osgi.container.Module.start(Module.java:463)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1852)
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1845)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1786)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1750)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1672)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)
  1. window opens up. This window when resized in such a way that content cannot be shown in same page, then scrolling is enabled. Even then text is allowed to be selected in the right manner

image

  1. Now you select/scroll. Only after your first scroll is done, i am seeing the problem you reported. Not able to see the selected content highlighted on that window anymore. image I am ideally selecting line4 and line5. But the blue highlighting(this is not correct) is happening somewhere else though font color changed to white(being correct).

Please let me know your comment on my observation.

TorstenU commented 1 year ago

Hi @deepika-u, I don't know the reason, why some dependencies are missing, but nevertheless ignoring that will reproduce the reported problem. Your screenshot exactly shows the problem. With best regards Torsten

elsazac commented 1 year ago

@TorstenU

Just tried this out in Mac OS with the zip file provided.The issue is seen in Mac OS as well. The selection works completely fine until any scrolling is done using the scroll bar.

The picture below shows before scrolling. The actual selected lines are the ones that are getting highlighted.

Screenshot 2023-04-11 at 1 36 13 PM

The picture below shows after scrolling down a little to the bottom. Here I tried to select the green portion but highlighting appeared somewhere below.The lines that I selected are not the ones that are getting highlighted.

Screenshot 2023-04-11 at 1 37 47 PM