changeset 21917:f500cde065f7

uicontrol: Escape '&' characters in Qt implementation (bug #48214) * ButtonControl.cc (ButtonControl::ButtonControl, ButtonControl::update): Escape all '&' characters in "string" property so they are not used by Qt to create a keyboard shortcut.
author Mike Miller <mtmiller@octave.org>
date Wed, 15 Jun 2016 18:23:15 -0700
parents 3a0c90b59584
children e4a53d9b28bd
files libgui/graphics/ButtonControl.cc
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/ButtonControl.cc	Tue Jun 14 14:53:33 2016 +0100
+++ b/libgui/graphics/ButtonControl.cc	Wed Jun 15 18:23:15 2016 -0700
@@ -39,7 +39,9 @@
 {
   uicontrol::properties& up = properties<uicontrol> ();
 
-  btn->setText (Utils::fromStdString (up.get_string_string ()));
+  QString str = Utils::fromStdString (up.get_string_string ());
+  str.replace ("&", "&&");
+  btn->setText (str);
   if (btn->isCheckable () || up.style_is ("togglebutton"))
     {
       btn->setCheckable (true);
@@ -67,8 +69,12 @@
   switch (pId)
     {
     case uicontrol::properties::ID_STRING:
-      btn->setText (Utils::fromStdString (up.get_string_string ()));
-      break;
+      {
+        QString str = Utils::fromStdString (up.get_string_string ());
+        str.replace ("&", "&&");
+        btn->setText (str);
+        break;
+      }
 
     case uicontrol::properties::ID_VALUE:
       m_blockCallback = true;