select MenuItem

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

select MenuItem

Post by Nakia » Tue Mar 13, 2012 10:59 pm

Hi Again,

I am trying to simulate an option button being pressed and an item being selected from its options.

-- I am trying
select menuItem 1 of btn "Fig1_Seq1"
--
But this only occasionally works, only worked once in fact?

this button has some scripts in its mouse up that I am looking to trigger..

any ideas?

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: select MenuItem

Post by Nakia » Tue Mar 13, 2012 11:11 pm

okay so this works if i have manually clicked the button at least once before trying to use this. but, i have another function which resets the label of these buttons and once this is ran I am back to the same situation. have to manually select it and select a value for the select menuItem function to work again?

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

Re: select MenuItem

Post by mwieder » Tue Mar 13, 2012 11:22 pm

Code: Select all

set the menuHistory of button "Fig1_Seq1" to 1

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: select MenuItem

Post by Nakia » Wed Mar 14, 2012 12:10 am

use this as well?
or replace menuItem with menuItem History

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: select MenuItem

Post by Nakia » Wed Mar 14, 2012 12:34 am

still no good.

here is the code I have from the card script
on zeroSequence
--Zero all 12 Figures
select menuItem 1 of button "Seq1_Fig1"
select menuItem 1 of button "Seq1_Fig2"
select menuItem 1 of button "Seq1_Fig3"
select menuItem 1 of button "Seq1_Fig4"
select menuItem 1 of button "Seq1_Fig5"
select menuItem 1 of button "Seq1_Fig6"
select menuItem 1 of button "Seq1_Fig7"
select menuItem 1 of button "Seq1_Fig8"
select menuItem 1 of button "Seq1_Fig9"
select menuItem 1 of button "Seq1_Fig10"
select menuItem 1 of button "Seq1_Fig11"
select menuItem 1 of button "Seq1_Fig12"
--
end zeroSequence


and here is the script from one of the button
--
on menuPick pItemName
put "DATA=1 - " & pItemName & " - -" into line 8 of field "ScoreRunS1"
end menuPick
Last edited by Nakia on Wed Mar 14, 2012 1:01 am, edited 1 time in total.

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

Re: select MenuItem

Post by mwieder » Wed Mar 14, 2012 12:49 am

No.

Not

Code: Select all

select menuItem 1 of button "Seq1_Fig1"
Instead

Code: Select all

set the menuHistory of button "Seq1_Fig1" to 1

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: select MenuItem

Post by dunbarx » Wed Mar 14, 2012 12:52 am

I am having trouble understanding what you are doing. Are you trying to invoke the popup itself externally, that is, to make the option list appear, not by clicking on the actual button, but via a click somewhere else or from a handler running somewhere? If so, write back. I wrote a script to do this years ago. I can probably find it, or rewrite it.

Craig Newman

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: select MenuItem

Post by Nakia » Wed Mar 14, 2012 12:55 am

mwieder wrote:No.

Not

Code: Select all

select menuItem 1 of button "Seq1_Fig1"
Instead

Code: Select all

set the menuHistory of button "Seq1_Fig1" to 1
doesnt work

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: select MenuItem

Post by Nakia » Wed Mar 14, 2012 12:59 am

dunbarx wrote:I am having trouble understanding what you are doing. Are you trying to invoke the popup itself externally, that is, to make the option list appear, not by clicking on the actual button, but via a click somewhere else or from a handler running somewhere? If so, write back. I wrote a script to do this years ago. I can probably find it, or rewrite it.

Craig Newman
No,
I don't need the popup to display.
I simply have a button which calls zeroSequence (in above code)
When this is pressed I need the 12 buttons to action their script with "0" in pItemName ( as if someone selected the button and selected "0" from its option)
the button script inserts this data into a field..

make sense?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: select MenuItem

Post by dunbarx » Wed Mar 14, 2012 5:25 am

We are getting closer, I think. I am certain that there are many better ways to do what you want, however, whenever we figure out what that actually is. This is going to be fun. Really.
I think that you are trying to use the "select" command in the wrong way, as if this will invoke a handler in an option menu. It will not.

So you have 12 buttons. Is it true that if you manually clicked on each of them, you would select the first menuItem, and each would do something you want? Is there a "menuPick" handler that is invoked in each button so that "pItemName", as you say, and the first line in the menu would start it?

And so, are you trying, in a single click on one button, to run "zeroSequence", which will set in motion those 12 different "actions", on those 12 different buttons? Again, by "actions" do you mean invoke handlers? Write back if this is so.

In the meantime, for something completely different, does this make sense to you:

on mouseUp
repeat with y = 1 to 12
send "menuPick" && line 1 of btn ("Seq_Fig" & y) to btn ("Seq_Fig" & y) --parentheses for clarity
end repeat
end mouseUp

When I said this would be fun, I meant it. There will certainly be a way to work through your set-up. LiveCode will prevail. It seems that the way you are going about it might be a little out of the ordinary. But we will see. Write back....

Craig Newman

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: select MenuItem

Post by Nakia » Wed Mar 14, 2012 6:40 am

Thanks for your reply..

It is not true that the item that is generally selected is item 1..

Each of the 12 buttons uses its own MenuPick Message to perform its task.
-- see below example of the script in button number 1
on menuPick pItemName
put "DATA=1 - " & pItemName & " - -" into line 8 of field "ScoreRunS1"
end menuPick

So this function I am trying to create "ZeroSeq" (which is triggered by another button) needs to simulate each of the buttons being pressed and selecting "0" from its option list (as if someone actually manually performed this task) Obviously the popup doesnt need to appear...

The idea is its a shortcut to simulate someone actually pressing on each of these buttons and selecting "0" from its option list.
this is for a score keeping App I am writing..

I was previously doing this by (on the card script) changing the label of each of the buttons to "0" and writing the data to the field line by line but it seemed really long winded ( but it worked :D )

I'm sure there is a better way to do it..

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: select MenuItem

Post by Nakia » Wed Mar 14, 2012 6:51 am

on mouseUp
repeat with y = 1 to 12
send "menuPick" && line 1 of btn ("Seq_Fig" & y) to btn ("Seq_Fig" & y) --parentheses for clarity
end repeat
end mouseUp


PERFECT THANKYOU.......

Post Reply