Page 1 of 1
Menubar Selected item
Posted: Wed Jan 11, 2017 4:26 am
by Xacto
I am trying to create a menubar with multiple choices (ex: Blue, Black,Red). When selected, it changes the color of a button on the stack. What I was wondering... how can I create a "check mark" next to the menu item that was just selected?
Here is what I have:
Code: Select all
on menuPick pItemName
switch pItemName
case "Black"
set the icon of button buttonFace to Blackicon.png
// NEED TO UNCHECK PREVIOUS SELECTION AND CHECK CURRENT SELECTION
break
case "Blue"
--code here
break
case "Red"
--- code
--code here
break
end switch
end menuPick
Thanks in advance!!!

Re: Menubar Selected item
Posted: Wed Jan 11, 2017 1:25 pm
by jmburnod
Hi Xacto,
I always use btns for menus with this script to display a checkmark.
You may also have a look to menuhistory.
Code: Select all
on menuPick pItemName
DoMyCheckMark the label of the target
switch pItemName
case "Black"
break
case "Blue"
--code here
break
end switch
set the label of the target to pItemName
end menuPick
on DoMyCheckMark pLabel
if pLabel = empty then exit DoMyCheckMark
put the text of the target into tPrevText
replace "!c" with empty in tPrevText
replace "!c" with empty in pItemName
put lineoffset(pLabel & cr, tPrevText & cr) into tMH
put "!c" before line tMH of tPrevText
set the text of the target to tPrevText
end DoMyCheckMark
Best regards
Jean-Marc
Re: Menubar Selected item
Posted: Thu Jan 12, 2017 2:43 am
by Xacto
Thank you so much... it is "somewhat" working. I have to select the menu item TWICE before the checkmark shows.
In your code you have:
Code: Select all
if pLabel = empty then exit FaitCheckMark
I get an error on this line. In order to make it run, I changed it to this:
Code: Select all
if pLabel = empty then exit DoMyCheckMark
Is the reason it does not always work?
Thanks again

Re: Menubar Selected item
Posted: Thu Jan 12, 2017 5:44 pm
by jmburnod
I have to select the menu item TWICE before the checkmark shows.
Ni idea. Do you use a btn menu ?
I get an error on this line
Yes, I changed it
Re: Menubar Selected item
Posted: Fri Jan 13, 2017 3:50 am
by Xacto
No, not a button - It is the system menubar item. Created with the "Menu Builder"
Re: Menubar Selected item
Posted: Fri Jan 13, 2017 3:52 am
by dunbarx
All menus in the menubar are formed from a group of buttons with certain properties set. The menu builder just helps that process along.
This may not be pertinent to the problem.
Craig
Re: Menubar Selected item
Posted: Fri Jan 13, 2017 5:15 am
by Xacto
Here is an example of what is happening. (see attachment)
The menu selects the color correctly, however you have to select the menu two times before it puts a check mark next to the menu item.
Re: Menubar Selected item
Posted: Sat Jan 14, 2017 5:06 pm
by jmburnod
I played a bit with your stack and I discover that The target of a btn of a menu group return the name of group and not the name of the clicked btn.
Here is a stack with menu and popup btn with same behavior.
They use the same script (in stack)
Jean-Marc
Re: Menubar Selected item
Posted: Mon Jan 16, 2017 2:34 pm
by MaxV
Wow,
I tried intead of "!c" on my linux machine these:
and I got these: ยป
It can be handy.
Re: Menubar Selected item
Posted: Wed Jan 18, 2017 2:18 am
by Xacto