# wxComboBox and wxTE\_PROCESS\_ENTER

**URL:** <https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475>\
**Category:** wxRuby\
**Created:** [November 30, 2008, 10:33am UTC](https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475 "2008-11-30T10:33:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [November 30, 2008, 10:33am UTC](https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475/1 "2008-11-30T10:33:33Z")

</div>

Hi all,

i am trying to use wxComboBox (instead of wxChoice) to capture  
wxTE\_PROCESS\_ENTER event.

If i enable TE\_PROCESS\_ENTER flag on the resulting xrc file, i get an  
‘Unknown style flag wxTE\_PROCESS\_ENTER’ on app loading.

Probably wxComboBox doesn’t reconize this kind of event.

How do i catch this event for the wxComboBox widget?

Thank you all.

bio.

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [November 30, 2008, 6:01pm UTC](https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475/2 "2008-11-30T18:01:55Z")

</div>

On Sun, Nov 30, 2008 at 10:27 AM, Fabio P.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Hi all,
> 
> i am trying to use wxComboBox (instead of wxChoice) to capture  
> wxTE\_PROCESS\_ENTER event.
> 
> If i enable TE\_PROCESS\_ENTER flag on the resulting xrc file, i get an  
> ‘Unknown style flag wxTE\_PROCESS\_ENTER’ on app loading.
> 
> Probably wxComboBox doesn’t reconize this kind of event.

> How do i catch this event for the wxComboBox widget?
> 
> Thank you all.
> 
> bio.

Wx::TE\_PROCESS\_ENTER can be set programmatically by  
window#toggle\_window\_style(Wx::TE\_PROCESS\_ENTER)

…now it works, but enabling this flag, the widget loose TAB controls  
(TAB  
/ SHIFT+TAB)

To try it out, on the ‘BigDemo → wxComboBox’ example if i add this flag

on line 23:

cb = Wx::ComboBox.new(self, 500, “default value”, Wx::Point.new(90,50),  
Wx::DEFAULT\_SIZE,  
sampleList,  
Wx::CB\_DROPDOWN|Wx::TE\_PROCESS\_ENTER)

i get the enter event but no tabbing is possible.

Is it a bug?

Thank you for your help.

bio

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [November 30, 2008, 7:14pm UTC](https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475/3 "2008-11-30T19:14:00Z")

</div>

The problem lies in the fact, that Wx::ComboBox has a Drop down, and a  
Text  
Edit in it. I believe that Fabio wants the Enter event, so that he can  
add  
what a person enters into the Drop Down, if I am understanding  
correctly.  
The best thing to do, is to monitor evt\_keypress, and create a new item,  
and  
update that item in the combo box, as the person types stuff into it.  
Either that, or monitor on focus lost, and check to see if the item is  
in  
the combo box, if not, add it. Though, that can lead to it’s own  
problems,  
as a person could switch between the controls several times, and have  
several items added if he changes the text each and every time he tabs  
between the controls.

Just a couple of suggestions on how to work around it.

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [November 30, 2008, 6:08pm UTC](https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475/4 "2008-11-30T18:08:21Z")

</div>

Fabio P. wrote:

> Wx::TE\_PROCESS\_ENTER can be set programmatically by  
> window#toggle\_window\_style(Wx::TE\_PROCESS\_ENTER)
> 
> …now it works, but enabling this flag, the widget loose TAB controls  
> (TAB / SHIFT+TAB)

The fact that setting this style when the control is created suggests to  
me that it’s not really meant to work like that, and I don’t understand  
what you’re trying to do here. Why do you want a ComboBox that processes  
ENTER?

> cb = Wx::ComboBox.new(self, 500, “default value”,  
> Wx::Point.new(90,50), Wx::DEFAULT\_SIZE,  
> sampleList,  
> Wx::CB\_DROPDOWN|Wx::TE\_PROCESS\_ENTER)
> 
> i get the enter event but no tabbing is possible.
> 
> Is it a bug?

I don’t know. I expect if the control is told to consume ENTER, it also  
consumes TAB.

alex

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [December 1, 2008, 12:31am UTC](https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475/5 "2008-12-01T00:31:40Z")

</div>

Hi Alex & Mario,

i am working on an invoice form, where the user should be able to fill  
fields using mainly tab, numeric keys and confirm by enter on every  
field  
he’s working on. The basic reason for that, is the user should only type  
on  
the keyboard avoiding as much as possible using mouse for speed reason.

On Sun, Nov 30, 2008 at 7:11 PM, Mario S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The problem lies in the fact, that Wx::ComboBox has a Drop down, and a Text  
> Edit in it.

right.

> I believe that Fabio wants the Enter event, so that he can add what a  
> person enters into the Drop Down, if I am understanding correctly.

Basically i use Enter to validate user input

> The best thing to do, is to monitor evt\_keypress

Is ComboBox able to trigger keypress event??

On Sun, Nov 30, 2008 at 11:06 AM, Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Fabio Petrucc  
> > The fact that setting this style when the control is created suggests to  
> > me that it’s not really meant to work like that, and I don’t understand  
> > what you’re trying to do here. Why do you want a ComboBox that processes  
> > ENTER?

The above user inserts hundreds of products a day and he knows exactly  
what  
vat code to use for that kind of product, without having to choose from  
a  
dropdown menu. The ENTER is to confirm what he typed.

ComboBox let you do that quite well standardizing behaviour between  
fields.

> > I don’t know. I expect if the control is told to consume ENTER, it also  
> > consumes TAB.

Unfortunately, on ComboBox, if you enable enter you loose the  
opportunity to  
use the tab

thank you both.

bio.

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [December 1, 2008, 6:33pm UTC](https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475/6 "2008-12-01T18:33:32Z")

</div>

Ok i’ve found my way:

Now my ComboBox consumes ENTER and TAB keys 🙂

One more question:

I use window#navigate() to simulate TAB.  
calling it by default param is fine even if it doesn’t reconize the  
mapping  
constant Wx::NavigationKeyEvent::IsForward

what about if i’d like to navigate backward?

i supposed a constant like Wx::NavigationKeyEvent::IsBackward

but i get an uninitialized constant  
Wxruby2::Wx::NavigationKeyEvent::IsBackward

any suggestion?

regards.

bio

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [December 1, 2008, 6:57pm UTC](https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475/7 "2008-12-01T18:57:12Z")

</div>

Fabio P. wrote:

> what about if i’d like to navigate backward?
> 
> i supposed a constant like Wx::NavigationKeyEvent::IsBackward
> 
> but i get an uninitialized constant  
> Wxruby2::Wx::NavigationKeyEvent::IsBackward

Try using the following values to indicate backwards and forwards to  
Window#navigate (never even knew about that method until today…)

IsBackward = 0  
IsForward = 1

alex

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [December 1, 2008, 9:04pm UTC](https://www.ruby-forum.com/t/wxcombobox-and-wxte-process-enter/154475/8 "2008-12-01T21:04:02Z")

</div>

* * *

wxruby-users mailing list  
removed\_email\_address@domain.invalid  
[http://rubyforge.org/mailman/listinfo/wxruby-users](http://rubyforge.org/mailman/listinfo/wxruby-users)
