Wrong menu text when it contains forward slashes
-
I wrote a Ruby script that adds a Context menu item called: "Draw Curve/ArcCurve/Circle Center-point". It appears correctly when the menu is shown by right-clicking or pressing the menu key (between Alt and Ctrl on the right side of a 104-key keyboard) but under "Edit|<Type-and/or-number-of-selected-item(s)> e.g. Edit|Arc" it only shows up as "Circle Center-point".
I tried putting the string in single quotes and in double-quotes with the forward slashes escaped with back-slashes (restarting SU after each change). There was no change in either menu after either change.
I'm running the latest free version of SU (7.0.10247) under 32-bit Win XP Pro SP3.
-
try putting double slashes instead of singles. Ive got a feeling theyre needed as slashes are ruby operators (or something along those lines) so you need to distinguish them.
-
@remus said:
try putting double slashes instead of singles.
Didn't help... Here's some other things I've tried:
# menu.add_item("Draw Curve\/ArcCurve\/Circle Center-point") { # slash_workaround = '/' # menu.add_item("Draw Curve#{slash_workaround}ArcCurve#{slash_workaround}Circle Center-point") {
@remus said:
Ive got a feeling theyre needed as slashes are ruby operators (or something along those lines) so you need to distinguish them.
I thought so too at first, but I checked all the Ruby docs I could find and they only mention strings delineated by slashes (regular expressions) but nothing about slashes inside a string. Then I realized that it has to be a bug in SU because it shows up fine in the popup context menu. Plus, I got this from the SU console:
puts 'Draw Curve/ArcCurve/Circle Center-point' Draw Curve/ArcCurve/Circle Center-point nil
I've settled on 'Draw Center-point of Curve, ArcCurve, or Circle' until the problem is sorted out. I suppose I should try harder to figure out which of those things is actually selected, but I'm too lazy
BTW, I've attached the plugin. It still might have bugs/quirks... The internal "ReadMe" stuff:
curve_tools.rb; (C) 2009 Amos Bieler ("find_center" method based on code by Chris Fullmer, because my version was ugly ;) -=_+ Description; This Ruby code can be useful to both modelers and plugin writers. -=_+ Modelers; As a tool for modelers, it is used to draw a construction point at either the center point of a Curve, ArcCurve or Circle entity, or at the point where the perpendiculars of two Edges intersect. The latter effect is handy when an ArcCurve or Circle has been exploded for any reason, such as being Push/Pull'ed. Usage; Select and context-click on a curve or at least two Edges and select The option ending in the phrase "Center-point" (it changes depending on what is selected). -=_+ Authors; As a tool for plugin authors, it adds the "center" and "radius" methods to Curve objects. In SketchUp's standard API, these methods are only available to the ArcCurve class and its derivatives. It also adds a "find_center" method to the Edge class to facilitate the above-mentioned effects. Usage; require 'curve_tools' puts curve_object.center.to_s (0.0", 0.0", 0.0") nil -or- puts edge_object.find_center(other_edge).to_s (0.0", 0.0", 0.0") nil -=_+ History 2009-08-10 - Initial release
-
You can't include '/' in menu titles... Try using a '|'. '...' or ':' instead.
-
@tig said:
You can't include '/' in menu titles ON WINDOWS... Try using a '|'. '...' or ':' instead.
Todd
-
With all due respect to those who have replied, I can and have used slashes in menu items - both in SU plugins and in general Windows development environments. You can check for yourself: open Notepad. At the very bottom of the Edit menu you'll find an item called "Time/Date". AFAIK, the only special character used by Windows menus is the ampersand (&) used to underline the accelerator letter.
As I stated in my original post, slashes work fine in the Right-click context menu. The problem is the "mirror" context menu that appears as the last item in the Edit menu on the main menu bar.
I'll concede that it could be something I'm doing wrong, but if so it's an undocumented rule I'm breaking. It seems more likely to simply be a bug in SketchUp (perhaps in the Windows version only; I can't test on a Mac). Either way, I'm not really complaining, I just wanted to point it out. It's an odd bug, but not a deal-breaker.
BTW, TIG, thanks for the replacement suggestions. I think the "pipe" might work just as well as the commas I switched to.
-
We stand corrected - I have tested it on v7 and you are right '/' do [now] work in menu titles...
However, up to v6 I found that using a '/' in a SUp Windows menu title caused the '/' and any following characters to disappear - that's why some of my tools' sub-menus have ':' or '|' - simply because the '/' was failing !
Perhaps it was fixed quietly in a v7 update ?
-
hm... I'm nto sure. I remember having issued with the forward slash myself - I develop and test in SU7 mainly.
-
I'm glad they fixed it. I remember reporting it as a bug some time ago.
Advertisement