diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-03-02 11:28:55 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-02 11:28:55 +1100 |
commit | 3893151fe217a684aba77669bab6ca3b828943e7 (patch) | |
tree | 2616c70d9fa2ec2a2f01462327bc07b984579b26 /source/windowing/StarWidgetLuaBindings.cpp | |
parent | 3e89b9cabf9b56f337b6b953d2222b56969d7375 (diff) | |
parent | 63d8c8e8db0a80f9dc98f98e845bc4654060ada4 (diff) |
Merge pull request #203 from KrashV/new-widget-callbacks
Bring new widget callbacks
Diffstat (limited to 'source/windowing/StarWidgetLuaBindings.cpp')
-rw-r--r-- | source/windowing/StarWidgetLuaBindings.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/windowing/StarWidgetLuaBindings.cpp b/source/windowing/StarWidgetLuaBindings.cpp index 16ef279..89eef00 100644 --- a/source/windowing/StarWidgetLuaBindings.cpp +++ b/source/windowing/StarWidgetLuaBindings.cpp @@ -205,6 +205,36 @@ 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<TextBoxWidget>(widget)) + textBox->setHint(hint); + } + }); + + callbacks.registerCallback("getHint", [parentWidget](String const& widgetName) -> Maybe<String> { + if (auto widget = parentWidget->fetchChild(widgetName)) { + if (auto textBox = as<TextBoxWidget>(widget)) + return textBox->getHint(); + } + return {}; + }); + + callbacks.registerCallback("setCursorPosition", [parentWidget](String const& widgetName, int cursorPosition) { + if (auto widget = parentWidget->fetchChild(widgetName)) { + if (auto textBox = as<TextBoxWidget>(widget)) + textBox->setCursorPosition(cursorPosition); + } + }); + + callbacks.registerCallback("getCursorPosition", [parentWidget](String const& widgetName) -> Maybe<int> { + if (auto widget = parentWidget->fetchChild(widgetName)) { + if (auto textBox = as<TextBoxWidget>(widget)) + return textBox->getCursorPosition(); + } + return {}; + }); + callbacks.registerCallback("getText", [parentWidget](String const& widgetName) -> Maybe<String> { if (auto widget = parentWidget->fetchChild(widgetName)) { if (auto label = as<LabelWidget>(widget)) |