On Apr 6, 2012, at 10:44 PM, Charles Szasz wrote: > on menuPick theMenuItem > set the itemDelimiter to "|" > switch item 1 of theMenuItem ---the submenu name > case "Font" > set the textFont of field "Example Text"\ > to item 2 of theMenuItem > break > case "Size" > set the textSize of field "example Text"\ > to item 2 of theMenuItem > break > case "Plain" > ---Plain removes all styles: > set the textStyle of field "example text" to empty > break > case "Bold" ---These two remaining menu items > break > case" Italic" ---are handled with the same piece of code! > break > put the textStyle of field "example text" into currentStyle > set the itemDelimiter to comma > if theMenuItem is among the items of currentStyle then > ---already has that style, so remove it > delete item (itemOffset(theMenuItem,currentStyle))\ > of currentStyle > else > ---add the style to any existing styles > if currentStyle is "Plain" > then put theMenuItem into currentStyle > else put comma & theMenuItem after currentStyle > end if > set the textStyle of field "Example Text" to currentStyle > end switch > end menuPick
Well, one problem is that you have breaks at the top of 2 sections, which will exit you without any action. It looks as if you want this instead: on menuPick theMenuItem set the itemDelimiter to "|" switch item 1 of theMenuItem ---the submenu name case "Font" set the textFont of field "Example Text"\ to item 2 of theMenuItem break case "Size" set the textSize of field "example Text"\ to item 2 of theMenuItem break case "Plain" ---Plain removes all styles: set the textStyle of field "example text" to empty break case "Bold" ---These two remaining menu items **** no break case" Italic" ---are handled with the same piece of code! **** no break put the textStyle of field "example text" into currentStyle set the itemDelimiter to comma if theMenuItem is among the items of currentStyle then ---already has that style, so remove it delete item (itemOffset(theMenuItem,currentStyle))\ of currentStyle else ---add the style to any existing styles if currentStyle is "Plain" then put theMenuItem into currentStyle else put comma & theMenuItem after currentStyle end if set the textStyle of field "Example Text" to currentStyle break end switch end menuPick -- Peter Peter M. Brigham pmb...@gmail.com http://home.comcast.net/~pmbrig _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode