TextInputCanvas How To Receive 'Other' Key Events

We are converting our RB Canvas + Carbon TSM based editor to Xojo + Cocoa by replacing the relevant code with the TextInputCanvas.

We have dead key / input method editing working for CJK so all good.

However, what we cannot seem to do is detect other key events and process them. For example, we have the shortcut CMD= to increase the font size and CMD- to decrease the font size. I was expecting that the = and - keys would get passed to the TIC KeyFallsThrough event or possibly the standard KeyDown event (like they do with a normal canvas). Unfortunately, neither event gets triggered. Looking at the TIC source code on GitHub it appears that the KeyFallsThrough event is not even hooked up as the FireKeyFallsThrough c++ method is not called from anywhere.

We could solve this by putting all of our shortcuts into the Edit Menu, use a timer + async key events or possibly hook into the events via the MBS plugins but that all seems messy and unnecessary.

I know there won’t be many people using TextInputCanvas but before I go down one of these routes is there anybody got this type of thing working?

Thanks

Wouldn’t the CMD= and CMD- just be simple Menu Handlers looking at the text selection? I wouldn’t expect that to be part of the Text Input Canvas.

I sort of expected the Text Input Canvas to pass through key events that it didn’t handle itself. The KeyFallsThrough event seems to indicate that there should be a mechanism to do this but it appears that the plugin never triggers the event.

A normal canvas gives me a mouse down event containing = or - for the key. I can then test for the CMD key via Keyboard. This is what I do for my current text editor which uses a canvas + declares into the Carbon TSM.

Menu Handlers would solve it but it does mean adding all of the options into a menu which I currently avoid doing.

Yeah, it’s kind of weird because using the command key doesn’t produce anything in the KeyDown event either. Perhaps @Joe Ranieri can provide some insight since, I believe, he’s the one that wrote TIC.

[quote=361898:@Kevin Gale]We are converting our RB Canvas + Carbon TSM based editor to Xojo + Cocoa by replacing the relevant code with the TextInputCanvas.

We have dead key / input method editing working for CJK so all good.

However, what we cannot seem to do is detect other key events and process them. For example, we have the shortcut CMD= to increase the font size and CMD- to decrease the font size. I was expecting that the = and - keys would get passed to the TIC KeyFallsThrough event or possibly the standard KeyDown event (like they do with a normal canvas). Unfortunately, neither event gets triggered. Looking at the TIC source code on GitHub it appears that the KeyFallsThrough event is not even hooked up as the FireKeyFallsThrough c++ method is not called from anywhere.

We could solve this by putting all of our shortcuts into the Edit Menu, use a timer + async key events or possibly hook into the events via the MBS plugins but that all seems messy and unnecessary.

I know there won’t be many people using TextInputCanvas but before I go down one of these routes is there anybody got this type of thing working?

Thanks[/quote]

Do you only care about macOS?

Hi Joe.

I can probably say yes to your question.

On MS-Windows we plan to continue treating the Text Input Canvas as a normal canvas - ie: use the KeyDown events and ignore the TIC events. This is because the Text Input Canvas doesn’t implement the same Imm events we already support (WM_IME_COMPOSITION / WM_IME_REQUEST) so we are going to continue sub-classing the WndProc and handle input method editing ourselves.

What I also noticed (and what also appears to be logged in GitHub) is that there is some inconsistency in how the different operating systems handle the KeyDown event in the plugin. macOS fires KeyDown if IsEditable returns false while MS-Windows fires KeyDown all of the time. That doesn’t bother us as we will do what we need for each platform. The reason why I mentioned it is that we don’t want to lose the ability to treat the TIC as a normal canvas under MS-Windows.

Finally, It would be useful to have some official 32 bit & 64 bit plugins for this rather than relying on @Christian Schmitz to build them.