Project

General

Profile

Actions

Bug #1899

closed

Push Button with Popup Menu loses caret on text change.

Added by Plug Gulp almost 11 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
05/08/2013
Due date:
% Done:

0%

Estimated time:

Description

Hello,

When a popup menu is attached to a push button a caret appears at the right of the push button text. But if the text is set explicitly using WPushButton::setText, after the popup menu is attached, the caret at the end of the push button text disappears. Following is a simple test:

<code class="cpp">
class TestApp : public WApplication
{
        public:
                TestApp(const WEnvironment& env)
                        : WApplication(env)
                {
                        setTheme(new WBootstrapTheme());

                        m_pButton = new WPushButton("Test 0", root());
                        WPopupMenu *m = new WPopupMenu();
                        m->addItem("Test 1");
                        m->addItem("Test 2");
                        m->triggered().connect(this, &TestApp::UpdateButton);
                        m_pButton->setMenu(m);
                }

        protected:
                void UpdateButton(WMenuItem *pMenuItem)
                {
                        m_pButton->setText(pMenuItem->text());
                }

        private:
                WPushButton *m_pButton;
};
</code>

Thanks and regards,

~Plug


Files

0001-Hack-fix-for-Bug-1899.patch (2.1 KB) 0001-Hack-fix-for-Bug-1899.patch Hack to fix the bug. Plug Gulp, 05/08/2013 10:21 PM
Actions #1

Updated by Plug Gulp almost 11 years ago

I managed to fix the issue. But it is a hack rather than a clean solution. For a clean solution, I think, some work will be required to separate themes from content rendering e.g. in the Bootstrap theme the "caret" is treated as part of theme but renderer treats it as content. This discrepancy in handling of the UI artifacts causes bugs such as these. The problem is further complicated when themes do not support the same UI artifacts e.g. the caret is supported by Bootstrap but not by default theme.

Actions #2

Updated by Koen Deforche almost 11 years ago

  • Status changed from New to Resolved
  • Assignee set to Koen Deforche
  • Target version set to 3.3.1

Hey,

Theme integration is necessarily a compromise between flexibility and keeping it simple. Rather than making the whole theme system more heavy, I've done something along your lines. Perhaps we will later migrate the caret trick into Wt entirely, or find a more general solution.

Regards,

koen

Actions #3

Updated by Koen Deforche over 10 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF