Re: Windows Input Method Editors and event box

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

 



Replying to myself .

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

Cheers,
Fredrik


On Thu, Feb 5, 2009 at 12:05 PM, Fredrik Corneliusson
<fredrik.corneliusson@xxxxxxxxx> 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.
>
> 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')
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux