From 588acfe31e6c39fa5f845c97590294cc0c5371bc Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 20 Feb 2021 19:14:22 +0100 Subject: [PATCH] DictQuickLookup: Properly scroll back to top when updating a ScrollTextWidget Despite a similar API between ScrollTextWidget and ScrollHtmlWiget, what they do internally doesn't quite match. So, while ScrollHtmlWidget's resetSCroll *does* rewind back to the top, ScrollTextWidget's doesn't, it just updates the scrollbar itself. So, do that on our end, *before* the (re-)init, which'll call _renderText for us. Fix #7318 --- frontend/ui/widget/dictquicklookup.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index 1c1961945..baeba9c77 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -816,9 +816,11 @@ function DictQuickLookup:update() self.text_widget.text_widget.lang = self.lang and self.lang:lower() self.text_widget.text_widget.para_direction_rtl = self.rtl_lang self.text_widget.text_widget.images = self.images + -- Scroll back to the top, àla TextBoxWidget:scrollToTop + self.text_widget.text_widget.virtual_line_num = 1 -- NOTE: The recursive free via our WidgetContainer (self[1]) above already free'd us ;) self.text_widget.text_widget:init() - -- Scroll back to top + -- Reset the scrollbar's state self.text_widget:resetScroll() else -- We jumped from HTML to Text (or vice-versa), we need a new widget instance