Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » bypassing default combo key reaction
bypassing default combo key reaction [message #466669] Thu, 12 January 2006 14:34 Go to next message
Spencer Stejskal is currently offline Spencer Stejskal
Messages: 9
Registered: July 2009
Junior Member
in a combo drop down box that is read only, the default behavior for a
KeyEvent is to jump to the first selection choice that begins with that
letter and subsequent key presses of the same type cycle through the
available selections that begin with that character. that being said, i
need a way to avoid this behavior entirely. any thoughts? thanks
spencer
Re: bypassing default combo key reaction [message #466670 is a reply to message #466669] Thu, 12 January 2006 14:42 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika Irvine
Messages: 1272
Registered: July 2009
Senior Member
Consume the key event:

Combo c = new Combo(shell, SWT.READ_ONLY);
c.add("asdasdasd");
c.add("retertert");
c.add("astyututyuy");
c.add("ghjghjghj");
c.add("ertetret");
c.add("rtyrty");
c.add("rtyt");
c.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
event.doit = false;
}
});

"Spencer Stejskal" <stejsks@sosstaffing.com> wrote in message
news:dq6b0t$124$1@utils.eclipse.org...
> in a combo drop down box that is read only, the default behavior for a
> KeyEvent is to jump to the first selection choice that begins with that
> letter and subsequent key presses of the same type cycle through the
> available selections that begin with that character. that being said, i
> need a way to avoid this behavior entirely. any thoughts? thanks
> spencer
>
Re: bypassing default combo key reaction [message #466675 is a reply to message #466670] Thu, 12 January 2006 16:46 Go to previous messageGo to next message
Spencer Stejskal is currently offline Spencer Stejskal
Messages: 9
Registered: July 2009
Junior Member
Thank you for your response. i tried that approach and it appears the
default behavior is performed before the general listeners are notified so
by the time i can consume the event, the default behavior has already
occured.
spencer
Re: bypassing default combo key reaction [message #466689 is a reply to message #466675] Fri, 13 January 2006 09:40 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika Irvine
Messages: 1272
Registered: July 2009
Senior Member
The following works for me on Windows XP. What platform are you using?
What version of SWT? Does this snippet fail for you? If not, can you make
it fail in the same way?

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new GridLayout());
Combo c = new Combo(shell, SWT.READ_ONLY);
c.add("asdasdasd");
c.add("retertert");
c.add("astyututyuy");
c.add("ghjghjghj");
c.add("ertetret");
c.add("rtyrty");
c.add("rtyt");
c.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
event.doit = false;
}
});
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

"Spencer Stejskal" <stejsks@sosstaffing.com> wrote in message
news:dq6iol$ene$1@utils.eclipse.org...
> Thank you for your response. i tried that approach and it appears the
> default behavior is performed before the general listeners are notified so
> by the time i can consume the event, the default behavior has already
> occured.
> spencer
>
Re: bypassing default combo key reaction [message #466808 is a reply to message #466689] Tue, 17 January 2006 14:46 Go to previous message
Spencer Stejskal is currently offline Spencer Stejskal
Messages: 9
Registered: July 2009
Junior Member
Thank you very much for your help. your snippet pointed out what was wrong
with my code. i was listening for a key up event and the default behavior
happens on a key down event, thats why it happened before my listener caught
it.
again thank you
spencer
"Veronika Irvine" <veronika_irvine@oti.com> wrote in message
news:dq8e4v$8pq$1@utils.eclipse.org...
> The following works for me on Windows XP. What platform are you using?
> What version of SWT? Does this snippet fail for you? If not, can you
> make it fail in the same way?
>
> public static void main (String [] args) {
> Display display = new Display ();
> Shell shell = new Shell (display);
> shell.setLayout(new GridLayout());
> Combo c = new Combo(shell, SWT.READ_ONLY);
> c.add("asdasdasd");
> c.add("retertert");
> c.add("astyututyuy");
> c.add("ghjghjghj");
> c.add("ertetret");
> c.add("rtyrty");
> c.add("rtyt");
> c.addListener(SWT.KeyDown, new Listener() {
> public void handleEvent(Event event) {
> event.doit = false;
> }
> });
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
> "Spencer Stejskal" <stejsks@sosstaffing.com> wrote in message
> news:dq6iol$ene$1@utils.eclipse.org...
>> Thank you for your response. i tried that approach and it appears the
>> default behavior is performed before the general listeners are notified
>> so by the time i can consume the event, the default behavior has already
>> occured.
>> spencer
>>
>
>
Previous Topic:Preventing Escape key on dialogs
Next Topic:StackLayout problem
Goto Forum:
  


Current Time: Wed Aug 27 07:13:59 EDT 2014

Powered by FUDForum. Page generated in 0.01705 seconds