Move IVirtualKeyboardEntry out of Slate

IVirtualKeyboardEntry looks pretty useful and basically independent of Slate. Slate is a large module that I’m not using at all but I’d like to use the virtual keyboard wrapper for its cross platform behavior.

Can we move the code into a place that doesn’t mean I have to link Slate into my application?

Well looks like you can use the keyboard out of slate - the following compiles on PC and IOS and pops up a keyboard on IOS when OnStartOpen is called.

Note that it does nothing on PC for me but that could be because I don’t have slate and in my case that’s fine, I’ll do my own key processing on PC.

Code:

[FONT=Courier New]
class VirtualKeyboardEntry : public IVirtualKeyboardEntry
{
FText Text;
FText HintText;
EKeyboardType KeyboardType = Keyboard_AlphaNumeric;

virtual void SetTextFromVirtualKeyboard(const FText& InNewText, ESetTextType SetTextType, ETextCommit::Type CommitType) override
{}

virtual const FText& GetText() const override
{return Text;}

virtual const FText GetHintText() const override
{return HintText;}

virtual EKeyboardType GetVirtualKeyboardType() const override
{return KeyboardType;}

virtual bool IsMultilineEntry() const override
{return false;}

public:
virtual ~VirtualKeyboardEntry(){}
};

RuntimeAccountSetupScreen::RuntimeAccountSetupScreen()
{
m_KeyboardEntry = MakeShareable(new VirtualKeyboardEntry);
}

void RuntimeAccountSetupScreen::OnStartOpen()
{
FSlateApplication& SlateApplication = FSlateApplication::Get();
if (FPlatformMisc::GetRequiresVirtualKeyboard())
{
SlateApplication.ShowVirtualKeyboard(true, 0, m_KeyboardEntry); //0 == userIndex
}
}

One issue though is that I don’t seem to be getting any callback when I cancel the text entry (from the API I’d expect ETextCommit::OnCleared).

This would be nice if possible!

Another issue is that I Do need to include slate - looks like its built in for standalone builds which is counterintuitive to me, as that’s where I’d expect the exe to be smaller and tighter. Adding the “slate” dependency in MyProject.Build.cs is required for the editor to compile.

While I’m starting Monday on a downer my three biggest issues with text entry right now are:

  • There is no callback on IOS for the cancel operation
  • My hint text worked for a text keyboard on IOS but seems to have stopped now, though when GetHintText is called in the above HintText contains the appropriate string.
  • It seems tricky to get localized text on PC without using the Slate edit widget (I don’t use Slate).

I do have somewhat functional text entry on IOS though and the weather is pretty good here today so its not all bad.