rdmenezes / cefpython

Automatically exported from code.google.com/p/cefpython
1 stars 0 forks source link

Text input not working in wxPython 2.9/3.x in wx/sample2.py and sample3.py examples #152

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. python2.7 + wx3.0 + cefpython 3.0
2. run C:\Python27\Lib\site-packages\cefpython3\examples\wx\sample3.py
3. navigate to any website such as "www.wikipedia.org", put mouse to a text 
input form and try to type text into it, nothing happens

What is the expected output? What do you see instead?
text input form can be input text by keyboard typing

What version of the product are you using? On what operating system?
window8.1/window8.0; python2.7 + wx3.0 + cefpython 3.0

Please provide any additional information below.
Sample1.py works fine. I test it by: modify sample1.py and set the url to some 
other website that contains text input forms such as bing.com and find the text 
input works!
the example wxpython.py also works!

Original issue reported on code.google.com by Zhouji...@gmail.com on 15 Dec 2014 at 1:28

GoogleCodeExporter commented 9 years ago
What CEF version? 31.1 is the latest. What wxPython version? Please paste the 
whole wx version string that is displayed in the wxpython.py example in console 
(see for example 
http://cefpython.googlecode.com/git/cefpython/var/wxpython.png).

sample3.py works fine for me with wx 2.8. Looks like an issue with the 
wxWidgets flatnotebook control in wx 3.0, the wx.WANTS_CHARS style is not 
applied. Make sure that yu have this line in sample3.py:

    self.tabs.SetWindowStyleFlag(wx.WANTS_CHARS)

Original comment by czarek.t...@gmail.com on 15 Dec 2014 at 7:40

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
See also  Issue 80  that explains in details the need for the wx.WANTS_CHARS 
style for the keyboard to work.

Original comment by czarek.t...@gmail.com on 15 Dec 2014 at 7:44

GoogleCodeExporter commented 9 years ago
the wx version string is "VERSION_STRING  = '3.0.1.1'"
the cefpython verison is "__version__ = "31.0"
I am sure following code exists in sample.py
 self.tabs.SetWindowStyleFlag(wx.WANTS_CHARS)
I will try 31.1 later

Original comment by Zhouji...@gmail.com on 16 Dec 2014 at 5:19

GoogleCodeExporter commented 9 years ago
I can confirm this issue. Tested with cefpython3 31.2 for Python 2.7 64bit and 
wx.version=3.0.2.0 msw (classic). The issue occurs in both sample2.py and 
sample3.py. The sample1.py is running fine, because it embeds cef browser in 
main frame and there is no need to use the wx.WANTS_CHARS for main frame.

This issue should be reported to wxWidgets/wxPython 
(http://trac.wxwidgets.org/).

I haven't tested it yet on other platforms, but I think this is a Windows only 
issue.

In the meantime you can fix it by propagating the Char event manually to child 
windows. This can be done either with a global hook to wx.EVT_CHAR. Or if that 
doesn't work try wx.EVT_CHAR_HOOK. EVT_CHAR_HOOK is a Windows only event I 
think, kind of a hack for Windows issues with Char events. For more details on 
wx.EVT_CHAR_HOOK see: http://docs.wxwidgets.org/3.0/classwx_key_event.html . 

Original comment by czarek.t...@gmail.com on 20 Jan 2015 at 5:46

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
@comment #5: The fix to propagate Char events to child windows - may require 
using Windows API (pywin32 extension) to send Char events to CEF browser child 
windows. You can get native window handle (HWND) by calling 
browser.GetWindowHandle(). To send the Char event using pywin32 use this code:

  c = "a"
  win32api.SendMessage(hwnd, win32con.WM_CHAR, ord(c), 0)

To get browser object using chromectrl API use these methods:

  ChromeWindow.GetBrowser()
  ChromeCtrl.chromeWindow.GetBrowser()

Original comment by czarek.t...@gmail.com on 20 Jan 2015 at 6:04

GoogleCodeExporter commented 9 years ago
This issue occurs in both wxPython 2.9 and 3.x. In 2.8 wx.WANTS_CHARS style is 
applied fine.

Original comment by czarek.t...@gmail.com on 17 Mar 2015 at 8:11

GoogleCodeExporter commented 9 years ago
In wxPython 2.9 issue can be fixed in the wxpython.py example by setting the 
wx.WANTS_CHARS style on the top-level window.

   win_style = wx.DEFAULT_FRAME_STYLE|wx.WANTS_CHARS
   parent = wx.GetApp().GetTopWindow()
   parent.SetWindowStyle(win_style)

However this does not fix the problem in the sample2.py example.

Original comment by czarek.t...@gmail.com on 19 Mar 2015 at 5:57