From e9a67335409ccc75a95cf1093bedb47abc17861a Mon Sep 17 00:00:00 2001 From: Vladimir Krasheninnikov Date: Sat, 1 Mar 2025 20:31:48 +0100 Subject: Bring new textbox callbacks --- source/windowing/StarWidgetLuaBindings.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source/windowing/StarWidgetLuaBindings.cpp') diff --git a/source/windowing/StarWidgetLuaBindings.cpp b/source/windowing/StarWidgetLuaBindings.cpp index 16ef279..b36d2f6 100644 --- a/source/windowing/StarWidgetLuaBindings.cpp +++ b/source/windowing/StarWidgetLuaBindings.cpp @@ -205,6 +205,34 @@ LuaCallbacks LuaBindings::makeWidgetCallbacks(Widget* parentWidget, GuiReaderPtr // callbacks only valid for specific widget types + callbacks.registerCallback("setHint", [parentWidget](String const& widgetName, String const& hint) { + if (auto widget = parentWidget->fetchChild(widgetName)) { + if (auto textBox = as(widget)) + textBox->setHint(hint); + } + }); + + callbacks.registerCallback("getHint", [parentWidget](String const& widgetName) { + if (auto widget = parentWidget->fetchChild(widgetName)) { + if (auto textBox = as(widget)) + return textBox->getHint(); + } + }); + + callbacks.registerCallback("setCursorPosition", [parentWidget](String const& widgetName, int cursorPosition) { + if (auto widget = parentWidget->fetchChild(widgetName)) { + if (auto textBox = as(widget)) + textBox->setCursorPosition(cursorPosition); + } + }); + + callbacks.registerCallback("getCursorPosition", [parentWidget](String const& widgetName) { + if (auto widget = parentWidget->fetchChild(widgetName)) { + if (auto textBox = as(widget)) + return textBox->getCursorPosition(); + } + }); + callbacks.registerCallback("getText", [parentWidget](String const& widgetName) -> Maybe { if (auto widget = parentWidget->fetchChild(widgetName)) { if (auto label = as(widget)) -- cgit v1.2.3