Slate compile error in editor build

This doesn’t compile with me in editor builds:

class SMyEditableText : public SEditableText
{
public: 
	int m_iXOffset = 0;
	virtual FReply MoveCursor(FMoveCursor Args) override
	{
		if (Args.GetAction() == ECursorAction::MoveCursor)
		{
			m_iXOffset += Args.GetMoveDirection().X;
			m_iXOffset = FMath::Clamp(m_iXOffset, -GetText().ToString().Len(), 0);
		}

		return SEditableText::MoveCursor(Args);
	}
};

Instead I get link errors:

Module.MM_04.3_of_4.cpp.obj : error LNK2019: unresolved external symbol "public: enum ECursorAction __cdecl FMoveCursor::GetAction(void)const " (?GetAction@FMoveCursor@@QEBA?AW4ECursorAction@@XZ) referenced in function "public: virtual class FReply __cdecl SMyEditableText::MoveCursor(class FMoveCursor)" (?MoveCursor@SMyEditableText@@UEAA?AVFReply@@VFMoveCursor@@@Z) 2>Module.MM_04.3_of_4.cpp.obj : error LNK2019: unresolved external symbol "public: struct FIntPoint __cdecl FMoveCursor::GetMoveDirection(void)const " (?GetMoveDirection@FMoveCursor@@QEBA?AUFIntPoint@@XZ) referenced in function "public: virtual class FReply __cdecl SMyEditableText::MoveCursor(class FMoveCursor)" (?MoveCursor@SMyEditableText@@UEAA?AVFReply@@VFMoveCursor@@@Z)

I have Slate and SlateCore listed as ModuleDependenies, Code compiles (and executes) on standalone and IOS builds, I have deleted Intermediate, Saved and Binaries folders

Is this because FMoveCursor is not marked as SLATE_API and isn’t exported in which case can I request that it gets marked up for future revisions (or that ITextEditorWidget exposes the Caret position)?

Hey -

What class did you use as the parent for your class above? When I create a new class based on EditableText in the editor it creates a new UMyEditableText rather than SMyEditableText. Can you explain how your class is setup? There also seems to be an unresolved external issue with the ECursorAction enum, if this enum is defined in another class then that class needs to be included as well.

Cheers

Hi , the class is created by hand (its a custom Slate widget not your typical UObject, so you wouldn’t create it through the normal C++ class operations).

However U prefix might be fine! Does it compile? Do you then get the same compiler errors in the editor?

I’m stretching the use of the API a bit. Unreal doesn’t properly provide cross platform support for keyboard text input but it comes very very close to wrapping up the details in a nice way.

So I suspect that what I’m doing is not in the plan for you guys, but if that’s the case a little tweaking at your end would make it easier for people like myself who have their own UI solutions and no intention of switching to the Unreal UI solution to reuse the work already done.

In this case for my purposes overriding MoveCursor is really a second rate solution, preferably I’d get access to the caret position directly allowing me to draw my own cursor in my own UI.

But I might also be missing this already being available…

Hey -

Can you elaborate on what you’re wanting to accomplish? It sounds like you’re trying to create a UI system, correct? Is there any related code other than what was posted originally? Can you explain the steps in your setup so I can try to recreate the issue on my end?

Cheers

I have a UI system that works perfectly well for me and no intention on switching to slate wholesale. I can probably use slate for this particular UI element but it would be much easier to just have the caret position exposed and draw the text in my own UI. I don’t see any good reason not to expose this - hence making the request.

The ideal solution would probably to take a bunch of the slate text edit widget functionality and move it to a lower level platform class, it’s complicated (by necessity- the problem being solved is surprisingly hard) so those using unreal but not slate can take advantage of it.

To reproduce - copy and paste the code I put above into a custom c++ project and see if it compiles in the development editor configuration.

After investigating this further I found that your assumption about FMoveCursor not being marked with SLATE_API may be the issue. While we don’t intend to expose the API functionality since it is not a relevant need for everyone and would lead to bloating the engine, it is possible for programmers on development teams to implement the functionality themselves in source code if necessary.

Cheers