Im trying to get a specific widget to receive keyboard input if a certain condition is met, what I tried doing is:
class SBlenderStyleMoveRotateScaleEditableTextBox : public SEditableTextBox
{
public:
void OnFocusLost(const FFocusEvent& InFocusEvent) override;
};
void SBlenderStyleMoveRotateScaleEditableTextBox::OnFocusLost(const FFocusEvent& InFocusEvent)
{
if (bIsBlenderStyleMoveRotateScaleActivated /* this is the "condition" that needs to be met */) {
FSlateApplication::Get().SetKeyboardFocus(getEditableTextBoxPtr(), EFocusCause::SetDirectly);
}
//return Super::OnFocusLost(InFocusEvent); // Not necessarily related to my og question, but uncommenting this gets me an error complaining "error C2248: 'SBorder::Super': cannot access private typedef declared in class 'SBorder'". So Im not really sure how Im supposed to be able to forawrd the OnFocusLost event to the parent class?
}
where getEditableTextBoxPtr() returns a widget initialized with SNew(SBlenderStyleMoveRotateScaleEditableTextBox); FSlateApplication::Get().SetKeyboardFocus(getEditableTextBoxPtr(), EFocusCause::SetDirectly); The issue is, whenever I call: FSlateApplication::Get().GetKeyboardFocusedWidget().Get()->ToString(); it prints SViewport [SEditorViewport.cpp(56)] in console (which obviously isnt my widget).
Alternatively, if I can manually route input to my widget, that would also work for my usecase (its fine if if the other widget SViewport [SEditorViewport.cpp(56)] also receives input), however I had a go at this too without success (Im not sure how these methods are supposed to be called, so I just tried calling all the ones that seemed relevant based on there names) :
FGeometry editableTextBoxGeometry = getEditableTextBox()->GetTickSpaceGeometry();
getEditableTextBox()->OnFocusReceived(editableTextBoxGeometry, FFocusEvent(EFocusCause::SetDirectly, 0));
getEditableTextBox()->OnKeyChar(editableTextBoxGeometry, FCharacterEvent(TCHAR('0'), LastKeyDownEventLocal->GetModifierKeys(), FInputDeviceId(), false));
getEditableTextBox()->OnFinishedKeyInput();
getEditableTextBox()->Tick(editableTextBoxGeometry, FSlateApplication::Get().GetCurrentTime(), FSlateApplication::Get().GetDeltaTime());
getEditableTextBox()->OnKeyDown(editableTextBoxGeometry, *LastKeyDownEventLocal);
getEditableTextBox()->OnFinishedKeyInput();
getEditableTextBox()->OnKeyUp(editableTextBoxGeometry, *LastKeyUpEventLocal);
getEditableTextBox()->OnFinishedKeyInput();
I should also add that the code Im writing is for an editor-time plugin - so theres no playerController to read input from afaik, instead, Im currently using the IInputProcessor class to receive keyboard input (which in itself works fine - its just that I cant seem to make my widget make any use of that input) as the SWidget::onKeyChar/OnKeyDown/OnKeyUp events doesnt seem to do anything).