Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-dev] Accessibility (Screen Reader)

Hi Niraj,

Thanks for answering. The problem with this snippet is, that it uses "normal" table items, not owner drawn ones. Attached is a snippet with owner draw. It would be interesting how I can tell the screen reader the "text name/value" of a row. Thanks in advance.

--
Best regards,
Thomas Singer
=============
syntevo GmbH
www.syntevo.com


On 2020-06-18 11:52, Niraj Modi wrote:

Hi Thomas,
It should works on similar lines as below snippet from SWT snippets
https://www.eclipse.org/swt/snippets/ :
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet162.java

You could also take clues from other snippets from Accessibility section.
If it doesn't work-out, then share an example Snippet for your use-case ?

Regards,
Niraj Modi


From:	Thomas Singer <ts-swt@xxxxxxxxxxx>
To:	platform-dev@xxxxxxxxxxx
Date:	17-06-2020 01:47 PM
Subject:	[EXTERNAL] [platform-dev] Accessibility (Screen Reader)
Sent by:	platform-dev-bounces@xxxxxxxxxxx



Hi,

In our SWT based application we are using a lot of owner-drawn tables.
How we can provide information about selected rows (in compact and
detailed form) to a screen reader? I've tried something like

    table.getAccessible().addAccessible*Listener(new Accessible*() {
      ...
    });

but none of the listeners seems to make a change. Our tables still are
read as "1 of 197" in NVDA.

--
Best regards,
Thomas Singer
=============
syntevo GmbH
www.syntevo.com
_______________________________________________
platform-dev mailing list
platform-dev@xxxxxxxxxxx
To unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-dev





_______________________________________________
platform-dev mailing list
platform-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/platform-dev


import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
 * @author Thomas Singer
 */
public class OwnerDrawnTable {

	public static void main(String[] args) {
		final Display display = new Display();

		final Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		final Composite composite = new Composite(shell, SWT.NONE);
		composite.setLayout(new FillLayout());

		final Table table = new Table(composite, SWT.VIRTUAL | SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
		table.setHeaderVisible(true);

		table.setHeaderVisible(true);
		final Listener listener = event -> {
			final TableItem item = (TableItem)event.item;
			if (event.type == SWT.EraseItem) {
//					event.detail &= ~SWT.FOREGROUND;
			}
			else if (event.type == SWT.PaintItem) {
				event.gc.drawText("hello", event.x, event.y, true);
			}
			else if (event.type == SWT.MeasureItem) {
				event.width = 100;
			}
			else if (event.type == SWT.SetData) {
				final int index = table.indexOf(item);
				item.setData("Item " + index);
			}
		};
		table.addListener(SWT.EraseItem, listener);
		table.addListener(SWT.SetData, listener);
		table.addListener(SWT.MeasureItem, listener);
		table.addListener(SWT.PaintItem, listener);

		createColumn(SWT.LEFT, "Column 1", table);
		createColumn(SWT.LEFT, "Column 2", table);
		createColumn(SWT.LEFT, "Column 3", table);

		shell.setSize(500, 450);
		shell.open();

		table.setRedraw(false);
		try {
			table.setSortColumn(table.getColumn(1));
			table.setSortDirection(SWT.UP);

			table.setItemCount(50);
			table.clearAll();
			table.setSelection(0);
		}
		finally {
			table.setRedraw(true);
		}

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

		display.dispose();
	}

	private static void createColumn(int style, String text, Table table) {
		final TableColumn tableColumn = new TableColumn(table, style);
		tableColumn.setText(text);
		tableColumn.setWidth(100);
	}
}


Back to the top