From d44188d166f3363f11f1f9c7266f6f3c0c98ec46 Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 11 Jun 2019 19:41:33 +0200 Subject: [PATCH] ui-widgets: delay question dialog autosizing --- api/ui-widgets.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/ui-widgets.lua b/api/ui-widgets.lua index ddabd506..11328e07 100644 --- a/api/ui-widgets.lua +++ b/api/ui-widgets.lua @@ -762,8 +762,13 @@ function pfUI.api.CreateQuestionDialog(text, yes, no, editbox, onclose) question:SetHeight(textspace + inputspace + buttonspace + padding) local width = 200 - if question.text:GetStringWidth() > 200 then width = question.text:GetStringWidth() end - question:SetWidth( width + 2*padding) + + -- delay the auto sizing, to make sure the font rendering happened + question:SetScript("OnUpdate", function() + if question.text:GetStringWidth() > width then width = question.text:GetStringWidth() end + question:SetWidth( width + 2*padding) + this:SetScript("OnUpdate", nil) + end) end