Syntax: mouseUp mouseButtonNumber

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax: mouseUp mouseButtonNumber

Roger Eller
The script editor won't compile a mouseUp  handler with 1 2 or 3 as a
parameter.

on mouseUp 3
   do stuff
end mouseUp

I am trying to get a right-click to show a contextual menu on Windows.

~Roger
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Mike Bonner
The parameter is passed on, not set by you.  To do what you want it would
be more like

on mouseup pvar
if pvar is 3 then
do stuff

end if
end mouseup

On Thu, Sep 22, 2016 at 2:11 PM, Roger Eller <[hidden email]>
wrote:

> The script editor won't compile a mouseUp  handler with 1 2 or 3 as a
> parameter.
>
> on mouseUp 3
>    do stuff
> end mouseUp
>
> I am trying to get a right-click to show a contextual menu on Windows.
>
> ~Roger
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Roger Eller
Thanks Mike!  I don't think the docs could have been any muddier.  ;)

~Roger


On Thu, Sep 22, 2016 at 5:24 PM, Mike Bonner <[hidden email]> wrote:

> The parameter is passed on, not set by you.  To do what you want it would
> be more like
>
> on mouseup pvar
> if pvar is 3 then
> do stuff
>
> end if
> end mouseup
>
> On Thu, Sep 22, 2016 at 2:11 PM, Roger Eller <[hidden email]>
> wrote:
>
> > The script editor won't compile a mouseUp  handler with 1 2 or 3 as a
> > parameter.
> >
> > on mouseUp 3
> >    do stuff
> > end mouseUp
> >
> > I am trying to get a right-click to show a contextual menu on Windows.
> >
> > ~Roger
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Monte Goulding-2

> On 23 Sep 2016, at 7:27 AM, Roger Eller <[hidden email]> wrote:
>
> Thanks Mike!  I don't think the docs could have been any muddier.  ;)

We are happy to accept pull requests on the docs Roger if you can think or a way/where to clarify it. It seems more of a fundamental misunderstanding of what parameters are so it would be good to ensure we clearly explain that well somewhere in the docs because it’s assumed knowledge in most/all of the api docs just like what a variable is etc. However, I definitely think the examples in the mouseUp docs should include button number handling because it’s a common error not to filter out right clicks.

Cheers

Monte
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Roger Eller
http://quality.livecode.com/show_bug.cgi?id=18465

Cheers

~Roger
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Monte Goulding-2

> On 23 Sep 2016, at 8:15 AM, Roger Eller <[hidden email]> wrote:
>
> http://quality.livecode.com/show_bug.cgi?id=18465 <http://quality.livecode.com/show_bug.cgi?id=18465>
Thanks for that report. It addresses the example in the mouseUp docs but I still feel there’s a deeper issue we need to resolve here with assumed knowledge. Perhaps we need some deep linking to the script guide?
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Roger Eller
On Thu, Sep 22, 2016 at 6:35 PM, Monte Goulding <[hidden email]> wrote:

>
> > On 23 Sep 2016, at 8:15 AM, Roger Eller <[hidden email]>
> wrote:
> >
> > http://quality.livecode.com/show_bug.cgi?id=18465 <
> http://quality.livecode.com/show_bug.cgi?id=18465>
> Thanks for that report. It addresses the example in the mouseUp docs but I
> still feel there’s a deeper issue we need to resolve here with assumed
> knowledge. Perhaps we need some deep linking to the script guide?
>
>
Possibly.  But I learned long ago to never assume even the most basic
knowledge because "brain-farts" are a real problem.  ;)

~Roger
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

mwieder
On 09/22/2016 03:39 PM, Roger Eller wrote:

> Possibly.  But I learned long ago to never assume even the most basic
> knowledge because "brain-farts" are a real problem.  ;)

<g> Very much agreed.

But this isn't a problem with the mouseUp handler per se. When you
declare a handler ("on xxx" or "function xxx") you can't give it
explicit parameters at that time. And the script compiler properly
complains if you do. Instead you give the parameter a name and can then
use the name in the handler's code to do something, as in Mike's
example. All LC handlers work exactly this way, and the mouseUp handler
is no exception.

--
  Mark Wieder
  [hidden email]



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Monte Goulding-2
In reply to this post by Monte Goulding-2

> On 23 Sep 2016, at 8:35 AM, Monte Goulding <[hidden email]> wrote:
>
>
>> On 23 Sep 2016, at 8:15 AM, Roger Eller <[hidden email] <mailto:[hidden email]>> wrote:
>>
>> http://quality.livecode.com/show_bug.cgi?id=18465 <http://quality.livecode.com/show_bug.cgi?id=18465>
> Thanks for that report. It addresses the example in the mouseUp docs but I still feel there’s a deeper issue we need to resolve here with assumed knowledge. Perhaps we need some deep linking to the script guide?

Yay open source https://github.com/livecode/livecode/pull/4550 <https://github.com/livecode/livecode/pull/4550>

Cheers

Monte
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Roger Eller
In reply to this post by mwieder
If the syntax example had been pWhichBtn instead of mouseButtonNumber, I
"might" have recognized it as a parameter.

On Sep 22, 2016 8:26 PM, "Mark Wieder" <[hidden email]> wrote:

> On 09/22/2016 03:39 PM, Roger Eller wrote:
>
> Possibly.  But I learned long ago to never assume even the most basic
>> knowledge because "brain-farts" are a real problem.  ;)
>>
>
> <g> Very much agreed.
>
> But this isn't a problem with the mouseUp handler per se. When you declare
> a handler ("on xxx" or "function xxx") you can't give it explicit
> parameters at that time. And the script compiler properly complains if you
> do. Instead you give the parameter a name and can then use the name in the
> handler's code to do something, as in Mike's example. All LC handlers work
> exactly this way, and the mouseUp handler is no exception.
>
> --
>  Mark Wieder
>  [hidden email]
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

mwieder
On 09/22/2016 05:44 PM, Roger Eller wrote:
> If the syntax example had been pWhichBtn instead of mouseButtonNumber, I
> "might" have recognized it as a parameter.

Aha! Got it now.

--
  Mark Wieder
  [hidden email]



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

pmbrig
In reply to this post by Roger Eller
On Sep 22, 2016, at 4:11 PM, Roger Eller <[hidden email]> 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
[hidden email]

——————

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



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Roger Eller
On Tue, Sep 27, 2016 at 9:18 AM, Peter M. Brigham <[hidden email]> wrote:

> On Sep 22, 2016, at 4:11 PM, Roger Eller <[hidden email]>
> 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
> [hidden email]
>
> ——————
>
> 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
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Syntax: mouseUp mouseButtonNumber

Bob Sneidar-2
In reply to this post by mwieder
What the compiler is complaining about is likely that you cannot have a variable start with a number. This is essentially what Roger is doing with the parameter arguement. He is putting a parameter passed by the event into a variable called "2". I'm not sure this is a documentation issue, so much as a fundamental understanding issue. I know a lot about those kind! :-)

Bob S


> On Sep 22, 2016, at 17:26 , Mark Wieder <[hidden email]> wrote:
>
> On 09/22/2016 03:39 PM, Roger Eller wrote:
>
>> Possibly.  But I learned long ago to never assume even the most basic
>> knowledge because "brain-farts" are a real problem.  ;)
>
> <g> Very much agreed.
>
> But this isn't a problem with the mouseUp handler per se. When you declare a handler ("on xxx" or "function xxx") you can't give it explicit parameters at that time. And the script compiler properly complains if you do. Instead you give the parameter a name and can then use the name in the handler's code to do something, as in Mike's example. All LC handlers work exactly this way, and the mouseUp handler is no exception.
>
> --
> Mark Wieder
> [hidden email]
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode