changeset 29913:3eca54836f97

Allow 'Label' to be used as a synonym for 'Text' on uimenus (bug #60870) * NEWS: Announce change in Matlab compatibility section. * graphics.in.h (PROPERTIES(uimenu)): Add string_property "text". Change "label" property to have custom get/set routines. * graphics.in.h (get_label, set_label): New functions which intercept get/set of "label" property and forward calls to get_text()/set_text(). * Menu.cc (Menu::Menu, Menu::update): Replace instances of get_label() with get_text().
author Rik <rik@octave.org>
date Thu, 22 Jul 2021 13:40:03 -0700
parents da5cc930ff10
children daf351544539
files NEWS libgui/graphics/Menu.cc libinterp/corefcn/graphics.in.h
diffstat 3 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Jul 22 11:39:14 2021 -0700
+++ b/NEWS	Thu Jul 22 13:40:03 2021 -0700
@@ -178,6 +178,10 @@
 - The function `importdata` now produces more compatible results when
 the file contains a 2-D text matrix.
 
+- `uimenu` now accepts property `"Text"` which is identical to
+`"Label"`.  Matlab recommends using `"Text"` in new code, although there
+is no announced date for deprecating `"Label"`.
+
 - The functions `scatter` and `scatter3` now return a handle to a
 scatter graphics object.  For compatibility, they return an `hggroup` of
 patch graphics objects when the `"gnuplot"` graphics toolkit is used.  In
--- a/libgui/graphics/Menu.cc	Thu Jul 22 11:39:14 2021 -0700
+++ b/libgui/graphics/Menu.cc	Thu Jul 22 13:40:03 2021 -0700
@@ -87,7 +87,7 @@
   {
     uimenu::properties& up = properties<uimenu> ();
 
-    action->setText (Utils::fromStdString (up.get_label ()));
+    action->setText (Utils::fromStdString (up.get_text ()));
 
     if (up.is_checked ())
       {
@@ -175,8 +175,8 @@
 
     switch (pId)
       {
-      case uimenu::properties::ID_LABEL:
-        action->setText (Utils::fromStdString (up.get_label ()));
+      case uimenu::properties::ID_TEXT:
+        action->setText (Utils::fromStdString (up.get_text ()));
         break;
 
       case uimenu::properties::ID_CHECKED:
--- a/libinterp/corefcn/graphics.in.h	Thu Jul 22 11:39:14 2021 -0700
+++ b/libinterp/corefcn/graphics.in.h	Thu Jul 22 13:40:03 2021 -0700
@@ -5752,15 +5752,27 @@
       bool_property checked , "off"
       bool_property enable , "on"
       color_property foregroundcolor , color_values (0, 0, 0)
-      string_property label , ""
+      string_property label gs , ""
       double_property position , 0
       bool_property separator , "off"
+      string_property text , ""
 
       // Octave-specific properties
       string_property __fltk_label__ h , ""
       any_property __object__ h , Matrix ()
     END_PROPERTIES
 
+    // Redirect calls from "Label" to "Text".
+    std::string get_label (void) const
+    {
+      return get_text ();
+    }
+
+    void set_label (const octave_value& val)
+    {
+      set_text (val);
+    }
+
   protected:
     void init (void)
     {