Re: MS Windows Input Method Editors and event box



Replying to myself .

I worked around this issue by doing an explicit call to the through
the Windows IME API when activating the widget.
I attached the code if someone else would find it helpful.

Cheers,
Fredrik

On Mon, Feb 9, 2009 at 4:55 PM, Fredrik Corneliusson
<fredrik corneliusson gmail com> wrote:
> Hi,
> I have a problem with IME (Global Input Method Editors) on MS Windows
> (Hindi,Japanese etc.).
>
> When a TextView is packed inside a Event box the selected IME looses
> it's binding to it when it's state is changed to insensitive or
> hidden. (This is not the case if it's not in an event box.)
>
> I found out that by hiding and raising the main window it is
> reattached. However I obviously do not want to do that every time if I
> can avoid it.
>
> Any idea's of ways of telling the IME to rebind? Or even better avoid
> loosing the IME binding altogether.
>
> BTW,
> I asked this on the GTK list last week but I figured this list might
> be more appropriate hope it's ok.
>
> Regards,
> Fredrik
>
import ctypes
from ctypes.wintypes import HWND,DWORD,BOOL

prototype = ctypes.WINFUNCTYPE(DWORD, HWND)
ImmGetContext = prototype(("ImmGetContext", ctypes.cdll.Imm32))

prototype = ctypes.WINFUNCTYPE(DWORD, HWND,DWORD)
ImmReleaseContext = prototype(("ImmReleaseContext", ctypes.cdll.Imm32))

prototype = ctypes.WINFUNCTYPE(BOOL, HWND,BOOL)
ImmSetOpenStatus = prototype(("ImmSetOpenStatus", ctypes.cdll.Imm32))

prototype = ctypes.WINFUNCTYPE(BOOL, DWORD)
ImmGetOpenStatus = prototype(("ImmGetOpenStatus", ctypes.cdll.Imm32))

def enable_ime(hWnd):
    '''
    Enable IME input for a gdk Window. 
    @hWnd: the gdk windows handle (gdk.Window.handle)
    '''
    hImc = ImmGetContext(hWnd)
    if hImc:
        # Get current IME status
        if not ImmSetOpenStatus(hImc, True):
            print "Error setting ImmSetOpenStatus"
        # Release input context
        if not ImmReleaseContext(hWnd, hImc):
            print "Error doing ImmReleaseContext"
    else:
        raise ValueError('could not get ImmGetContext')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]