wxTEXT_ENTER problem in Windows

I just transferred an application from Linux to Windows and I’m getting a problem with wx.EVT_TEXT_ENTER; it is acting like a tab key after the ‘enter’ key is pressed rather than triggering the event it is supposed to. The problem occurs on a ComboBox. It worked fine on my Linux laptop. I have not used ‘style=wx.TE_PROCESS_ENTER’ for the combobox. Is this necessary in Windows but not in Linux?

Thanks,

Mike

Michael Barron wrote:

I just transferred an application from Linux to Windows and I'm getting a problem with wx.EVT_TEXT_ENTER; it is acting like a tab key after the 'enter' key is pressed rather than triggering the event it is supposed to. The problem occurs on a ComboBox. It worked fine on my Linux laptop. I have not used 'style=wx.TE_PROCESS_ENTER' for the combobox. Is this necessary in Windows but not in Linux?

Interesting coincidence, I just ran into this today too with a wxDatePickerCtrl, where I would like to catch that enter event. I can confirm that enter acts as a tab on XP but does nothing in wxgtk. I will look forward to any hints :slight_smile:

- Mike

Michael Barron wrote:

I just transferred an application from Linux to Windows and I'm getting a problem with wx.EVT_TEXT_ENTER; it is acting like a tab key after the 'enter' key is pressed rather than triggering the event it is supposed to. The problem occurs on a ComboBox. It worked fine on my Linux laptop. I have not used 'style=wx.TE_PROCESS_ENTER' for the combobox. Is this necessary in Windows but not in Linux?

The enter key is used as a navigation key on Windows, and depending on the widget type it may or may not be possible to capture the event for it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Michael Barron wrote:

I just transferred an application from Linux to Windows and I'm getting a problem with wx.EVT_TEXT_ENTER; it is acting like a tab key after the 'enter' key is pressed rather than triggering the event it is supposed to. The problem occurs on a ComboBox. It worked fine on my Linux laptop. I have not used 'style=wx.TE_PROCESS_ENTER' for the combobox. Is this necessary in Windows but not in Linux?

The enter key is used as a navigation key on Windows, and depending on the widget type it may or may not be possible to capture the event for it.

Any idea if this is possible with the DatePickerCtrl, either native on Windows, or with the Generic? I assume the generic is more likely, and has the possibility to implement it later if desired. If so (with the generic), I can just force the generic one on Windows to get this functionality.

Thanks!
- Mike

Mike Rooney wrote:

Robin Dunn wrote:

Michael Barron wrote:

I just transferred an application from Linux to Windows and I'm getting a problem with wx.EVT_TEXT_ENTER; it is acting like a tab key after the 'enter' key is pressed rather than triggering the event it is supposed to. The problem occurs on a ComboBox. It worked fine on my Linux laptop. I have not used 'style=wx.TE_PROCESS_ENTER' for the combobox. Is this necessary in Windows but not in Linux?

The enter key is used as a navigation key on Windows, and depending on the widget type it may or may not be possible to capture the event for it.

Any idea if this is possible with the DatePickerCtrl, either native on Windows, or with the Generic? I assume the generic is more likely, and has the possibility to implement it later if desired. If so (with the generic), I can just force the generic one on Windows to get this functionality.

There is a good way to find out. Try it and see.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Mike Rooney wrote:

Any idea if this is possible with the DatePickerCtrl, either native on Windows, or with the Generic? I assume the generic is more likely, and has the possibility to implement it later if desired. If so (with the generic), I can just force the generic one on Windows to get this functionality.

There is a good way to find out. Try it and see.

Well, I guess what I meant to imply was that I did try it in the previously discussed way of binding to wx.EVT_TEXT_ENTER, and then trying to pass wx.TE_PROCESS_ENTER to the style of the control (I tried both DatePickerCtrl and GenericDatePickerCtrl on Windows), but still Enter just moved to the next control. So I was wondering if you knew of something else I should try.

I am able to access the TextCtrl via dateCtrl.Children[0].Children[0], but since it already exists I am not sure how to make it process the enter. Is there a way to give wx.TE_PROCESS_ENTER to an existing text ctrl? Failing that, I guess I could get extra hacky and replace its text control with one that I create myself, with the process enter flag?

- Mike

Mike Rooney wrote:

Robin Dunn wrote:

Mike Rooney wrote:

Any idea if this is possible with the DatePickerCtrl, either native on Windows, or with the Generic? I assume the generic is more likely, and has the possibility to implement it later if desired. If so (with the generic), I can just force the generic one on Windows to get this functionality.

There is a good way to find out. Try it and see.

Well, I guess what I meant to imply was that I did try it in the previously discussed way of binding to wx.EVT_TEXT_ENTER, and then trying to pass wx.TE_PROCESS_ENTER to the style of the control (I tried both DatePickerCtrl and GenericDatePickerCtrl on Windows), but still Enter just moved to the next control. So I was wondering if you knew of something else I should try.

Sorry, I must have had something else on my mind when I wrote that.

I am able to access the TextCtrl via dateCtrl.Children[0].Children[0], but since it already exists I am not sure how to make it process the enter. Is there a way to give wx.TE_PROCESS_ENTER to an existing text ctrl?

It might work on wxMSW as the wx.TE_PROCESS_ENTER style is used on-the-fly in response to the WM_GETDLGCODE message. Try this:

  txt = dateCtrl.Children[0].Children[0]
  txt.WindowStyleFlag |= wx.TE_PROCESS_ENTER

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Mike Rooney wrote:

I am able to access the TextCtrl via dateCtrl.Children[0].Children[0], but since it already exists I am not sure how to make it process the enter. Is there a way to give wx.TE_PROCESS_ENTER to an existing text ctrl?

It might work on wxMSW as the wx.TE_PROCESS_ENTER style is used on-the-fly in response to the WM_GETDLGCODE message. Try this:

    txt = dateCtrl.Children[0].Children[0]
    txt.WindowStyleFlag |= wx.TE_PROCESS_ENTER

Thanks, that actually works on MSW and GTK! Would you not have expected it to work in GTK? It doesn't work however on MSW with wxPython < 2.8.8.0, because I can't force a GenericDatePickerCtrl (that I know of), which is needed to be able to access the children. Is it just a no-go in that case? It isn't a huge deal since I handled the possible non-existence of wx.GenericDatePickerCtrl and Children, and I don't mind requiring 2.8.8.0 on Windows for this feature. The main worry was not being able to have this in GTK at all, or requiring a newer version of wxPython than is in typical repos. However since Generic is the default there, it works fine.

Thanks so much!
- Mike

Mike Rooney wrote:

Robin Dunn wrote:

Mike Rooney wrote:

I am able to access the TextCtrl via dateCtrl.Children[0].Children[0], but since it already exists I am not sure how to make it process the enter. Is there a way to give wx.TE_PROCESS_ENTER to an existing text ctrl?

It might work on wxMSW as the wx.TE_PROCESS_ENTER style is used on-the-fly in response to the WM_GETDLGCODE message. Try this:

    txt = dateCtrl.Children[0].Children[0]
    txt.WindowStyleFlag |= wx.TE_PROCESS_ENTER

Thanks, that actually works on MSW and GTK! Would you not have expected it to work in GTK?

I didn't look at the wxGTK implementation before responding yesterday, but after taking a look it makes sense that it also works because the style is checked in the default character event. The wx styles that result in some native style or native API call being made in the constructor are the ones that usually can't be changed after construction.

It doesn't work however on MSW with wxPython < 2.8.8.0, because I can't force a GenericDatePickerCtrl (that I know of),

Correct. The wrappers for the generic control (using that name) were added in 2.8.8.0.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!