wxGrid should disable ime input on read-only cells (Issue #24558)

21 views
Skip to first unread message

Mark Roszko

unread,
May 25, 2024, 1:20:06 PM5/25/24
to wx-...@googlegroups.com, Subscribed

Currently, if you click on a wxGrid cell that is read-only and then start typing.
The IME will open in the far right corner of your display, in my case, on the other monitor

image.png (view on web)

If you click into editable cells, the IME will correctly show under that cell

image.png (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558@github.com>

VZ

unread,
May 25, 2024, 1:56:05 PM5/25/24
to wx-...@googlegroups.com, Subscribed

Hmm, I must be using a wrong locale because I don't see anything like this at all. I have "Chinese (Traditional, Taiwan) Microsoft Bopomofo" in the language switcher, which one do you use?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558/2131374561@github.com>

Mark Roszko

unread,
May 25, 2024, 2:26:57 PM5/25/24
to wx-...@googlegroups.com, Subscribed

Hmm, I must be using a wrong locale because I don't see anything like this at all. I have "Chinese (Traditional, Taiwan) Microsoft Bopomofo" in the language switcher, which one do you use?

Chinese traditional, ill explore further


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558/2131385051@github.com>

VZ

unread,
May 25, 2024, 2:57:35 PM5/25/24
to wx-...@googlegroups.com, Subscribed

Yes, I thought I installed the same locale that you used, but somehow I don't see this window at all. Do I need to press anything special to make it come up? I've tried checking if there're some options I could change, but I don't see any and after doing "Restore default IME settings" nothing seems to have changed.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558/2131393338@github.com>

Mark Roszko

unread,
May 25, 2024, 6:18:07 PM5/25/24
to wx-...@googlegroups.com, Subscribed

I can reproduce it in the grid sample.

Simply added

grid->SetReadOnly(0, 0);

below

grid->SetCellValue( 0, 0, "Ctrl+Home\nwill go to\nthis cell" );

When that corner cell is selected, and you start typing with

lCXO49Zwxn.gif (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558/2131553943@github.com>

Mark Roszko

unread,
May 25, 2024, 6:28:27 PM5/25/24
to wx-...@googlegroups.com, Subscribed

This fixes it for me

 include/wx/generic/private/grid.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/wx/generic/private/grid.h b/include/wx/generic/private/grid.h
index 9ada5661c0..e8cb2e5f41 100644
--- a/include/wx/generic/private/grid.h
+++ b/include/wx/generic/private/grid.h
@@ -392,6 +392,9 @@ public:
           m_type(type)
     {
         SetBackgroundStyle(wxBG_STYLE_PAINT);
+#ifdef __WXMSW__
+        ::ImmAssociateContext(GetHWND(), NULL);
+#endif
     }

The text input in cells still shows IME, the rest of the wxGrid won't show the IME


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558/2131570983@github.com>

VZ

unread,
May 25, 2024, 7:07:57 PM5/25/24
to wx-...@googlegroups.com, Subscribed

Thanks, I do see this with simplified Chinese (I still have no idea why does the IME for simplified and traditional Chinese work so differently...).

However I don't think disabling IME for the grid is the best solution because you should be able to start typing and make the cell editor appear with the character you've entered already in it — and this actually works even with the IME right now. With your patch, it doesn't work any more however.

Ideal would be to avoid showing the IME window only for the read-only cells, I'm going to see if I find a way to do it.

BTW, I suspect this problem is not MSW-specific neither.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558/2131636765@github.com>

Mark Roszko

unread,
May 25, 2024, 7:09:56 PM5/25/24
to wx-...@googlegroups.com, Subscribed

Thanks, I do see this with simplified Chinese (I still have no idea why does the IME for simplified and traditional Chinese work so differently...).

However I don't think disabling IME for the grid is the best solution because you should be able to start typing and make the cell editor appear with the character you've entered already in it — and this actually works even with the IME right now. With your patch, it doesn't work any more however.

Ideal would be to avoid showing the IME window only for the read-only cells, I'm going to see if I find a way to do it.

BTW, I suspect this problem is not MSW-specific neither.

Then it needs a two part fix .

Read-only cells need the ime disabled.

But also editable cells that don't have the editor triggered yet need the ime target set manually using another imm function because it also points the editor in space.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558/2131640561@github.com>

VZ

unread,
May 25, 2024, 7:45:59 PM5/25/24
to wx-...@googlegroups.com, Subscribed

I can prevent IME window from appearing (I think this one is the "candidate" window, right?) by not passing WM_KEYDOWN to DefWindowProc(), but I'd like to find some more precise way of doing it. Unfortunately WM_IME_NOTIFY doesn't seem to allow returning something to prevent this from happening and I don't know what else to try right now.

Positioning the window can be done with ImmSetCompositionWindow() but I'm not sure when to call it neither.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558/2131704229@github.com>

VZ

unread,
Dec 23, 2025, 1:02:48 PM (3 days ago) Dec 23
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#24558)

I'll try to do something about it before the next release. If anybody else has any hints/better ideas about how to fix this, please let me know.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24558/3687503210@github.com>

Reply all
Reply to author
Forward
0 new messages