Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Preventing focus with Tables etc
Preventing focus with Tables etc [message #458436] Wed, 13 July 2005 15:48 Go to next message
Dan is currently offline DanFriend
Messages: 20
Registered: July 2009
Junior Member
Hi

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.
Re: Preventing focus with Tables etc [message #458441 is a reply to message #458436] Wed, 13 July 2005 18:42 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
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.
Re: Preventing focus with Tables etc [message #458474 is a reply to message #458441] Thu, 14 July 2005 08:45 Go to previous messageGo to next message
Dan is currently offline DanFriend
Messages: 20
Registered: July 2009
Junior Member
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.
>>
Re: Preventing focus with Tables etc [message #458532 is a reply to message #458474] Thu, 14 July 2005 15:15 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
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.
Re: Preventing focus with Tables etc [message #458536 is a reply to message #458474] Thu, 14 July 2005 18:22 Go to previous message
Billy Biggs is currently offline Billy BiggsFriend
Messages: 94
Registered: July 2009
Member
Dan wrote:
> 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?

I assume you are using Linux-GTK+? The pop-up window is probably the
search window for the table or tree. This is how GTK+ does typeahead
searches. In GTK+ 2.6 and higher (or 2.4.x with Red Hat's patches), it
appears as you type. In prior versions, you could get to it by using
Ctrl+F.

I think that if you really need to avoid the searching, you could try
setting the doit flag to false in a key listener to avoid having the
Table see them.

-Billy
Previous Topic:Adding a Tab Folder to an ApplicationWindow
Next Topic:Please help with Browser Scrollbars
Goto Forum:
  


Current Time: Fri Apr 19 10:54:44 GMT 2024

Powered by FUDForum. Page generated in 0.01991 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top