|
|
|
Re: Preventing focus with Tables etc [message #458532 is a reply to message #458474] |
Thu, 14 July 2005 15:15 |
Konstantin Scheglov Messages: 555 Registered: July 2009 |
Senior Member |
|
|
Dan:
I don't understand about what pop-up you speak.
Here is small example, that shows all key down events.
I can even prevent passing this event into Table (commented line):
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
public class Z {
private Table m_Table;
protected Shell shell;
public static void main(String[] args) {
try {
Z window = new Z();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
public void open() {
final Display display = Display.getDefault();
display.addFilter(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
//event.doit = false;
System.out.println(event);
}
});
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
protected void createContents() {
shell = new Shell();
shell.setSize(405, 340);
shell.setText("SWT Application");
{
m_Table = new Table(shell, SWT.BORDER);
m_Table.setLinesVisible(true);
m_Table.setHeaderVisible(true);
m_Table.setBounds(40, 20, 290, 220);
{
final TableColumn newColumnTableColumn = new TableColumn(m_Table,
SWT.NONE);
newColumnTableColumn.setWidth(100);
newColumnTableColumn.setText("New column");
}
{
final TableItem aaaaaaTableItem = new TableItem(m_Table, SWT.BORDER);
aaaaaaTableItem.setText("aaaaaa");
}
{
final TableItem bbbbbbTableItem = new TableItem(m_Table, SWT.BORDER);
bbbbbbTableItem.setText("bbbbbb");
}
}
}
}
> Thanks Konstantin for your tip about using Display.addFilter to receieve all
> key presses at the Display. However, if a Table has the focus and I start
> typing, the first key press is received by the Display, but subsequent key
> presses result in the table getting a little pop-up window that shows the
> second and subsequent characters. I don't want the Table to receive the key
> presses. Can I prevent this behaviour?
>
> Cheers
> Dan
>
> Konstantin Scheglov wrote:
>
>
>>Dan:
>>
>> Display.addFilter
>>
>>
>>>I am writing a GUI client that is keyboard-oriented. I can capture key
>>>events with a listener on the Shell, and key events are detected with no
>>>problems. However, once other components (such as a Table) have received
>>>the focus, my Shell no longer gets the key events. In fact, a little
>>>pop-up appears which is getting key input on the Tables. I want to keep
>>>receiving key events at the Shell... am I missing something?
>>>
>>>Cheers
>>>Dan.
>>>
>
>
Konstantin Scheglov,
Google, Inc.
|
|
|
|
Powered by
FUDForum. Page generated in 0.01991 seconds