From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Menu ItemNames disregard first underscore character

Solved!
Go to solution

Are there any characters that are not valid in a LabVIEW custom ItemName?

 

If you create an ItemName such as 'One_Two_Three' under a File Item, or even at the top-level it is displayed wrong.

 

 

Item Name:  One_Two_Three

Displayed as: OneTwo_Three

 

It seems the first 'underscore' is being cutoff.  When displayed it actually looks like the T (in Two) is underlined.

 

Is that expected behavior? Smiley Frustrated

 

I was working on some code to display a Recently Used File List in the File menu.  I was hoping to just read the filename (as ItemNames) but items with an initial underscore are causing this error.  I suppose there are some workarounds where I could just replace all "_" with some other character but that seems like more work than is necessary.

 

Thanks,

PH

0 Kudos
Message 1 of 7
(3,547 Views)

I should mention:  Using LabVIEW 2010 SP1.

 

 

0 Kudos
Message 2 of 7
(3,545 Views)
Solution
Accepted by topic author Teds

Yes, it is expected behavior.

 

Using the underscore character ahead of a menu item defines that letter to be a shortcut for when you use the keyboard.  So it defines the T as the shortcut to pick that menu line.  Look at the regular LabVIEW menu and you'll see numerous menu items with underlined characters.

 

Is there a reason why you want to use an underscore character in your menu?  That is unusual and probably not recommended by some Microsoft UI guideline somewhere.

 

You could use a double underscore character for that first one.  Then it will appear as a single underscore character.  But then that will define the underscore as the shortcut key.  Or you could define a the letter O, n, or e as a shortcut, then that will free up that _T to become shown with an underscore and not defined as a shortcut of T.

0 Kudos
Message 3 of 7
(3,535 Views)

I wanted to put in the full path for recently used files in the File Menu.  It works fine except for paths with underscores in them.

 

Notice, though, what I said the 'underscore' is NOT at the beginning but it replaces the first underscore it sees, no matter where the position is located.

 

"One_Two_Three" is what I want to display in the menu.

 

What actually displayed is:

 

OneTwo_Three

 

So if any of my paths contain a "_" ANYWHERE in them it gets removed by LabVIEW as the ItemName.

 

Thanks,

PH

0 Kudos
Message 4 of 7
(3,519 Views)

I never said it was at the beginning of the menu item.  It is ahead of a character that you want to make a shortcut letter.  Often it is at the beginning such as before the F in File or S in Save., but it can be used anywhere in the menu item.

0 Kudos
Message 5 of 7
(3,513 Views)

Thank you for the response,

 

I am still in the process of adding a 'Recent Files' submenu from the File menu.  I wanted to display the FULL path to any files that the user recently opened. For example:

 

File -> Recent Files

 

Would display the full path, whatever that might be ( including any "_" characters ), such as these belo

C:\Program Files\Project1\Test2_2.INI

C:\Program Files\Project1\Test3_1.INI

 

I noticed that LabVIEW somehow gets around this,  if open a VI with a "_" character the correct filename is displayed in the 'File->Recent Files' submenu.

 

How do they manage to do that?  Is there some escape character for underscores? Smiley Surprised

 

My current workaround is to replace all "_" with "~" when displaying the item in the menu and then reversing the process when the user selects the file to display.

 

Thanks,

PH

 

 

 

0 Kudos
Message 6 of 7
(3,499 Views)

I found that if you add "__"  ( two underscores) for the first underscore it will resolve to display just one "_" in the ItemName displayed in the menu.    So my logic will have to read an INI file, where I keep the list of recent files opened, replace the first "_" with "__" and set this as the actual ItemName in my Recent Files menu.

 

When a user selects a Recent Files menu item, I will have go back the opposite way to change "__" back to "_" in the ItemName selected.

 

Smiley Very Happy

 

Thanks,

PH

0 Kudos
Message 7 of 7
(3,487 Views)