diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2023-03-09 12:04:36 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2023-03-21 12:36:31 +0000 |
commit | 33f97ddd549b4ebd72b5fea327378667d55796ff (patch) | |
tree | 0fd9a17e6cf3d04f8ec949252ffc632b5eb890fe /vcl | |
parent | 3911b23c89da02eca92a0069bf1035155b7fddae (diff) |
jsdialog: set text for textview on every key press
for that we need to set text without sending back notification
to not disturb user in typing
we need to keep the selection at the same place
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ib5c4a53e61dbc2cf28d450fb44fc5a2957ff57b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148533
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149191
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 1 | ||||
-rw-r--r-- | vcl/jsdialog/executor.cxx | 7 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 19458a938c02..0c6cbaa48080 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -666,6 +666,7 @@ public: JSTextView(JSDialogSender* pSender, ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership); virtual void set_text(const OUString& rText) override; + void set_text_without_notify(const OUString& rText); virtual void replace_selection(const OUString& rText) override; }; diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 5598afa8ba19..e0d0cbb323f3 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -361,12 +361,15 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM } } - auto pTextView = dynamic_cast<weld::TextView*>(pWidget); + auto pTextView = dynamic_cast<JSTextView*>(pWidget); if (pTextView) { if (sAction == "change") { - pTextView->set_text(rData["data"]); + int rStartPos, rEndPos; + pTextView->get_selection_bounds(rStartPos, rEndPos); + pTextView->set_text_without_notify(rData["data"]); + pTextView->select_region(rStartPos, rEndPos); LOKTrigger::trigger_changed(*pTextView); return true; } diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 2d73c26613da..3cfe67c3b56c 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1752,6 +1752,11 @@ void JSTextView::set_text(const OUString& rText) sendUpdate(); } +void JSTextView::set_text_without_notify(const OUString& rText) +{ + SalInstanceTextView::set_text(rText); +} + void JSTextView::replace_selection(const OUString& rText) { SalInstanceTextView::replace_selection(rText); |