popUp a button with itself on modified mouseDown?

Michael Doub mikedoub at gmail.com
Wed Jul 2 08:47:06 EDT 2014


Thanks Peter.  Very handy.

-= Mike

On Jul 2, 2014, at 8:16 AM, Peter Brigham <pmbrig at gmail.com> wrote:

> I'm late to this discussion but here's what I do. It's a modular solution,
> and I use it a lot. It's great for contextual menus for right-clicking in a
> field (customize the button contents depending on context) and I've often
> used it for just what you are doing, to offer a popup list on
> right-clicking a standard button. Once it's set up you will likely find
> yourself using it for lots of things, since calling it is as simple as:
>   put popChoose("Vera","Chuck","Dave","-","Lovely Rita","Nowhere Man")
> into uChoice
> 
> function popChoose
>   -- create a popup button in your mainstack or a library stack
>   --    button style = menu, menumode = popup, name = "contextualMenu"
>   --    button script:
>   --      on menupick what
>   --         set the uSelection of me to what
>   --      end menupick
>   -- make the button invisible when you're done, if needed
> 
>   -- then paste this 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.
> 
>   -- popChoose() can accept a cr-delimited list of choices
>   --    or a comma-delimited list
>   -- eg: put "Vera" & cr & "Chuck" & cr & "Dave" into choiceList
>   --     put popChoose(choiceList) into userChoice
>   -- or: put popChoose(choice1,choice2,choice3) into userChoice
>   -- or: put popChoose("One","Two","Three") into userChoice
> 
>   constant popChooseStackName = "yourLibraryStack"
> 
>   put the params into tList
>   put offset("(",tList) into q
>   delete char 1 to q of tList
>   delete char -1 of tList
>   replace comma & space & quote with comma & quote in tList
>   replace quote & comma & quote with cr in tList
>   if char 1 of tList = quote then delete char 1 of tList
>   if char -1 of tList = quote then 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 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
>   end if
>   return u
> end popChoose
> 
> -- Peter
> 
> Peter M. Brigham
> pmbrig at gmail.com
> http://home.comcast.net/~pmbrig
> 
> 
> On Mon, Jun 30, 2014 at 7:36 PM, Michael Doub <mikedoub at gmail.com> wrote:
> 
>> create a popup button
>> move it to -100,-100
>> 
>> create your standard visible button with the following script:
>> 
>> on mousedown thebutton
>>      popup button "x"
>>   else
>>      beep
>>   end if
>> end mousedown
>> 
>> Does this do what you want?
>> 
>> -= Mike
>> 
>> 
>> 
>> On Jun 30, 2014, at 7:19 PM, Dr. Hawkins <dochawk at gmail.com> wrote:
>> 
>>> On Mon, Jun 30, 2014 at 4:17 PM, Michael Doub <mikedoub at gmail.com>
>> wrote:
>>> 
>>>> Take a look at the button style, menumode and general appearance
>>>> properties.  I would think that you could dynamicly change the style and
>>>> menu mode and general appearance.   Just a thought….
>>> 
>>> 
>>> Within limits, it does that so far.
>>> 
>>> The code I have successfully changes the button type; my problem is
>> getting
>>> the now-popup to pop.
>>> 
>>> --
>>> Dr. Richard E. Hawkins, Esq.
>>> (702) 508-8462
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list