Lua: Expose hasFocus within TextEditor binding

Change-Id: Id16b4f78ccd0229ee1976be377df97ada1594c04
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Lukasz Papierkowski
2024-12-03 09:17:51 +01:00
committed by lie
parent 640f2bfb27
commit 094fefbd92
2 changed files with 11 additions and 0 deletions

View File

@@ -381,6 +381,13 @@ void setupTextEditorModule()
"insertText",
[](TextEditorPtr editor, const QString &text) {
editor->editorWidget()->multiTextCursor().insertText(text);
},
"hasFocus",
[](const TextEditorPtr &textEditor) {
QTC_ASSERT(
textEditor && textEditor->editorWidget(),
throw sol::error("TextEditor is not valid"));
return textEditor->editorWidget()->hasFocus();
});
result.new_usertype<TextSuggestion::Data>(

View File

@@ -150,6 +150,10 @@ function TextEditor:hasLockedSuggestion() end
---@param text string The text to insert.
function TextEditor:insertText(text) end
---Indicates if the editor widget has focus.
---@return boolean hasFocus True if the editor widget has focus, false otherwise.
function TextEditor:hasFocus() end
---Returns the current editor or nil.
---@return TextEditor|nil editor The currently active editor or nil if there is none.
function textEditor.currentEditor() end