Items with ( in first character grayed out

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
matthellstrom
Posts: 31
Joined: Mon Apr 27, 2015 3:09 pm

Items with ( in first character grayed out

Post by matthellstrom » Mon Apr 27, 2015 3:12 pm

In both the pulldown menu and option menu, if the first character in one of my choices is a left paren ( the choice is grayed out and unselectable. To test, just set up a new control and change the choices to:

(Choice 1)
Choice 2
(Choice 3)

You'll see that only Choice 2 is able to be selected. This is on a mac, I haven't tested it on a PC.

Also, the ( is missing in the selections for those 2 items.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Items with ( in first character grayed out

Post by Klaus » Mon Apr 27, 2015 3:37 pm

Hi Matt,

1. welcome to the forum! :D

2. This is correct behavior!
A left round bracket ( at the beginning of a menuitem indicates that this menuitem is DISABLED, as you have experienced.

You can force the character to appear and be part of your menuitem when you ESCAPE this character with a BACKSLASH.
Then the enigne knows that ( is part of the menuitem!

This should work in your menu:
\(Choice 1)
Choice 2
\(Choice 3)


Best

Klaus

matthellstrom
Posts: 31
Joined: Mon Apr 27, 2015 3:09 pm

Re: Items with ( in first character grayed out

Post by matthellstrom » Mon Apr 27, 2015 4:06 pm

OK great! Thanks!

matthellstrom
Posts: 31
Joined: Mon Apr 27, 2015 3:09 pm

Re: Items with ( in first character grayed out

Post by matthellstrom » Mon Apr 27, 2015 4:20 pm

Next problem is the label for the control has the \ in it. Is there a simple way to avoid that?

matthellstrom
Posts: 31
Joined: Mon Apr 27, 2015 3:09 pm

Re: Items with ( in first character grayed out

Post by matthellstrom » Mon Apr 27, 2015 4:32 pm

OK well I figured out how to do it with a function, but I'm wondering if there is an easier way. Here's what i did:

function corCheckEscape textToCheck
if char 1 to 2 in textToCheck = "\(" then
delete char 1 in textToCheck
end if
return textToCheck
end corCheckEscape

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Items with ( in first character grayed out

Post by Klaus » Mon Apr 27, 2015 5:07 pm

Hi Matt,

well, you MAY do this shorter with some regular expression, but that is still a complete mystery to me :D
Your function looks great, I would do it this way, too!


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Items with ( in first character grayed out

Post by jacque » Tue Apr 28, 2015 6:46 pm

The documented way to indicate that a character in a menu is a literal instead of a status designator is to double it. (In fact, I wasn't aware of the backslash solution until now.) So if you want to display the first parenthesis, you double it like this:

((Open)

And although it looks strange, to disable it you would add the disabling parenthesis, giving you three:

(((Open)

This works and you get the text you expect in the menuPick parameter without any alterations required. I have to add though that I have never seen a menu item with parentheses and I don't think it's standard behavior.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

matthellstrom
Posts: 31
Joined: Mon Apr 27, 2015 3:09 pm

Re: Items with ( in first character grayed out

Post by matthellstrom » Thu Apr 30, 2015 2:24 pm

I didn't see that documentation anywhere. I will try that.

The reason I have a ( in the first character is because that's in the data. It's a list of vendors, and one of them has that in its name. I have to allow for anything, within reason.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Items with ( in first character grayed out

Post by jacque » Thu Apr 30, 2015 5:04 pm

I couldn't find it in a quick search of the dictionary either, but it's in there somewhere. The convention dates back to the beginning of time.

If you're working with company names then yes, your approach makes sense now.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Items with ( in first character grayed out

Post by mwieder » Thu Apr 30, 2015 6:17 pm

Doubling? Really? :shock:
Learning something new every day.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Items with ( in first character grayed out

Post by jacque » Thu Apr 30, 2015 7:02 pm

Okay, I found it in the user guide and I was half wrong but it still works anyway. Here's what it says:
To put an & or / character in the text of a menu, double the characters: && or //.

Putting the ( character anywhere in a line disables the menu item. To put a ( character
in a menu item without disabling it, precede it with a backslash: \(.
So it seems that doubling is only supposed to disable "&" and "/" but it seems to work fine with "(" as well. I've always just doubled all the special characters without any problem. Apparently my brain can only hold one rule at a time.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply