Syntax: mouseUp mouseButtonNumber

Roger Eller roger.e.eller at sealedair.com
Tue Sep 27 10:14:59 EDT 2016


On Tue, Sep 27, 2016 at 9:18 AM, Peter M. Brigham <pmbrig at gmail.com> wrote:

> On Sep 22, 2016, at 4:11 PM, Roger Eller <roger.e.eller at sealedair.com>
> wrote:
> >
> > I am trying to get a right-click to show a contextual menu on Windows.
>
> Here is a modular way to to popup contextual menus anywhere you want. It
> takes a couple minutes to set up in a stack, but once you’ve done it, you
> have contextual menus on demand with just a line or Two of script.
>
> — Peter
>
> Peter M. Brigham
> pmbrig at gmail.com
>
> ——————
>
> function popChoose
>    -- popChoose() is the equivalent of the "answer" command, but for a
> pop-up list
>    -- pops up a list of options, returns the option chosen by the user,
>    --    if no option chosen, exits to top
>    -- you must have a button "contextualMenu"
>    --    button style = menu, menumode = popup, name = "contextualMenu"
>    --    the button should be placed in your mainstack or a library stack
>    --    button can be made invisible when you're done, if you like
>    -- the button script needs only one handler:
>    --    on menupick what
>    --       set the uSelection of me to what
>    --    end menupick
>    -- paste this popChoose handler into a suitable stack script,
>    --    so it's available anywhere --
>    --    could be the same stack the button is in, but that's not necessary
>    -- enter the short name of the stack containing the button
>    --    into the constant declaration below
>    -- this all sounds complicated, but believe me, it's worth the time --
>    --    once you install the handler and the button,
>    --    using popup lists is dead-simple
>
>    -- popChoose() can accept a cr-delimited list of choices
>    --    or a comma-delimited list
>    -- eg: put "parsley" & cr & "sage" & cr & "rosemary" into choiceList
>    --     put popChoose(choiceList) into userChoice
>    -- or: put popChoose(choice1,choice2,choice3) into userChoice
>    -- or: put popChoose("parsley","sage","rosemary","-","thyme") \
>       --           into userChoice
>    -- if you need the line number of the chosen item, check the dialogdata
>    --    after calling popChoose()
>
>    constant popChooseStackName = "yourLibraryStack"
>
>    repeat with n = 1 to paramcount()
>       put param(n) & cr after tList
>    end repeat
>    delete char -1 of tList
>    put empty into u
>    set the uSelection of btn "contextualMenu" of stack popChooseStackName
> to empty
>    put tList into btn "contextualMenu" of stack popChooseStackName
>    popup btn "contextualMenu" of stack popChooseStackName
>    put the menuhistory of btn "contextualMenu" of stack popChooseStackName
> \
>          into lineNbr
>    put the uSelection of btn "contextualMenu" of stack popChooseStackName
> into u
>    set the uSelection of btn "contextualMenu" of stack popChooseStackName
> to empty
>    put empty into btn "contextualMenu" of stack popChooseStackName
>    -- belt and suspenders, don't leave contents hanging around
>    select empty
>    if u = empty then exit to top
>    -- ie, mouseRelease, no action, otherwise:
>    set the dialogdata to lineNbr
>    return u
> end popChoose
>


Excellent!  Thank you for that, Peter.  I can put it to good use.

A related question:  When there is a list and the user clicks a line to
select it, (the selectedLine) is sometimes empty, even though it "appears"
to still be selected.  I think it happens when other clicks have occurred
outside the field.  So the user goes back and right-clicks an apparent
selected line, and becomes frustrated because they have to left-click it
again.  Why is this, and how can it be avoided?

~Roger



More information about the use-livecode mailing list